error caused by System.Net.dll in app_data and GAC

Topics: General, Troubleshooting
Jul 14, 2011 at 5:51 PM

has anyone else seen this problem?

CS0433: The type 'System.Net.HttpWebRequest' exists in both 'c:\Projects\blah\App_Data\Dependencies\System.Net.dll' and 'c:\Windows\Microsoft.NET\assembly\GAC_MSIL\System\v4.0_4.0.0.0__b77a5c561934e089\System.dll'

we're repeatedly getting this when running our code locally. It seems that Orchard is copying System.Net.dll into app_data?? Any ideas?

Coordinator
Jul 14, 2011 at 7:53 PM

Do you know where does this "System.net.dll" come from? What version is it? The one in the GAC from .NET 4.0 doesn't contain the type "System.Net.HttpWebRequest"?

The reason Orchard copies System.net.dll into App_Data is most likely that

1. you module references System.net in the .csproj file

2. *and* there is a version of System.net.dll in the bin directory of the module, i.e. "~/Modules/foo/bin/System.net.dll"

Does your module really need to reference System.net.dll?

Jul 14, 2011 at 8:04 PM

my modules don't reference System.Net - first thing I checked. They do use HttpWebRequest which is in System.dll (in the System.Net namespace).

It is appearing in the bin directories for my modules - even if I delete it - it comes back when I run orchard - but not every time!

Coordinator
Jul 14, 2011 at 10:54 PM

Can you use Reflector on that System.Net dll file? The one I'm getting from the 4.0 GAC doesn't contain the "System.Net.HttpWebRequest" type, so I'm not quite sure what's going on there.  We need to figure out where the assembly comes from. Could it be one of your module dependencies targets an earlier version of the Frx and you are running into a multi-targetting weirdness?

Jul 14, 2011 at 11:55 PM

OK Its the silverlight System.Net dll. We have a silverlight player on our site, although the modules do not (and don't need to) reference System.Net.dll

I dont get where its pulling it from, or why?

Coordinator
Jul 15, 2011 at 12:27 AM

It might be Visual Studio. If your module references another project (module or not), VS will bring all the referenced assemblies of the references to the "bin" folder of the module. The reason is each module is considered a Web Application by msbuild.

Jul 19, 2011 at 10:18 AM

OK figured it out. For some reason some of our modules referenced System.Windows.dll although it wasn't required. Everytime VS compiled these modules it was dragging in System.Net.dll as well. Removed all references from the csproj files and we're back on track. Thanks for the help