views:

42

answers:

1

Hello everyone,

I am using VSTS 2010 + C# + .Net 4.0 + IIS 7.5 + Windows 7. When I open a WCF svc file in IIS 7.0, there is some error like this, any ideas what is wrong?

System.BadImageFormatException: Could not load file or assembly 'foo.test' or one of its dependencies.

thanks in advance, George

+1  A: 

Probably the application pool is configured to target CLR 2.0. You need to change it to target .NET 4.0:

alt text

Also make sure .NET 4.0 is registered by running:

%WINDIR%\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe -i
Darin Dimitrov
It is configured to 4.0. Any ideas to find more information, like which dependent assembly is looking for?
George2
Does this `foo.test` assembly mentioned in the exception have any other dependencies? Does it run unmanaged code?
Darin Dimitrov
For aspnet_regiis, I think it registers ASP.Net to IIS, not .Net 4.0?
George2
No it registers .NET 4.0 with IIS because you are running it from the v4.0.30319 folder.
Darin Dimitrov
"Does this foo.test assembly mentioned in the exception have any other dependencies? Does it run unmanaged code?" -- yes, it has some dependencies, but all are managed code. I have just tried the same process on a 32-bit machine, no issues. Anything wrong?
George2
"No it registers .NET 4.0 with IIS because you are running it from the v4.0.30319 folder" -- if I can see .Net 4.0 can be selected from IIS worker process pool, it means .Net 4.0 has already registered correct?
George2
That's what I thought as well. Had the same problem. I was getting 404 errors instead of `BadImageFormatException` until I ran this command even if I was seeing .NET 4.0 in the list before.
Darin Dimitrov
So, you suggest I re-run this command? Do I need to uninstall anything because my situation is different from yours (I can see .Net 4.0 from drop down list to select)?
George2
Yes try running the command. You don't need to uninstall anything. Note that I was also seeing the .NET 4.0 from the dropdown **before** running the command.
Darin Dimitrov
I have a new idea. I am using Microsoft Expression Encoder SDK 2.0. I think it only supports to run on 32-bit?
George2
Don't even know what this is :-) If it is an unmanaged library which is 32-bit only you need to [allow execution of 32-bit code in the app pool](http://3.bp.blogspot.com/_2TqL1T92L48/S_F1FQAmVeI/AAAAAAAAACQ/bnIay3Cg4HI/s1600/IIS7_Application_Pools_Enable_32-Bit_Applications.png).
Darin Dimitrov
In the [download page](http://www.microsoft.com/downloads/en/details.aspx?FamilyId=9A077A3D-58CE-454C-B486-153F0578BE4AWindows XP Service Pack 2. There's no Windows 7.
Darin Dimitrov
Looks like there are some issue to use it with 64-bit Windows. http://social.expression.microsoft.com/forums/en-US/encoder/thread/775b1f04-5b94-41cb-a6fa-c27eace3ee70/
George2
A new issue, after right clicking the specific application pool for the WCF application, and then select advanced settings, I can not find an item called enable 32-bit application, anything wrong? Should I install anything else to make this option available?
George2
You have to select the app pool and then Advance Settings... from right hand side action pane. You should see that as Second option in General Category. if not please give the screenshot of the Advance setting you are having
rauts
Thanks, question answered!
George2