tags:

views:

1051

answers:

9

I saw something about needing to have the assembly available for the type of the first argument passed to the function. I think it is, I can't figure out what am I missing.

This code is in a service. I was running the service under the 'NETWORK SERVICES' user account, when I changed the account to that of the session I was logged on with it worked ok. But, what's the difference, and how can I get it to work for the NETWORK SERVICES user.

A: 

I don't have the answer, but I get the same problem. Did you solve it?

In fact, my only difference is that my web server runs under the LocalSystem account, but it's the same error.
A: 

Network Service is a built in account that has very limited access (for good reason) to resources. You should probably not change it because you will open your site up to other potential vulnerabilities.

If you absolutely have to, see here for how to configure it to have access to other resources.

StingyJack
A: 

I finally found an answer: it appears that the type given to ApplicationHost.CreateApplicationHost() must be in an assembly located in the GAC. Simple, and stupid :)

picrap
Cool. Did you find this in some documentation I can look at... or was it by trial and error?
Scott Langham
voted down becuase the assembly does not need to be in the GAC
Simon
Indeed, it's not needed to put the assembly into the GAC. This has to do with Assembly binding. Put fusion logging on and you can exactly see where it goes wrong
Jeroen Landheer
A: 

I think this is related more closely to the Network Services account or Code Access Security and has nothing to do with the GAC. I am using CreateApplicationHost() to create an ASP.Net host in an MS Test project and it works like a champ. The type that I use is not in an assembly that is deployed to the GAC or even strongly named (It is defined in the TestProject).

You gotta love these types of inconsistencies... it keeps life interesting.

A: 

I had this problem as well. I think the runtime is trying to load the assembly containing the type passed as the first argument to CreateApplicationHost and it fails to find it

For some bizarre reason it worked when I created a bin directory in my physical directory (the third argument) containing the exe or assembly which contains the type it was trying to load.

I don't know why it does not look in the working directory first...

deltanine
A: 

sorry for my bad english!! bud for this give a look on which framework you are using ! use the .NET 1.1 and it gogogogogo with no exception but .NET>>1.1 I dont now why it donot support ApplicationHost.createApplicationHost???

+1  A: 

copy your binary to the bin folder of your web app will also fix this.

Chocoboboy
+1  A: 

By the way, this page has a little more information on this topic and a possible way to workaround the issue of GAC vs copying your assembly to the bin folder. The page is a few years old at this point but it still seems relevant.

Jason