3

We have a C# ASP.NET Web Application that uses the System.Transactions namespace.

using System.Transactions;

This works fine when developing locally - we just had to add the reference first by going to Website --> Add Reference...

The problem is that after deploying to the web host (copying over FTP), the host doesn't know this reference.

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS0234: The type or namespace name 'Transactions' does not exist in the namespace 'System' (are you missing an assembly reference?)

Working in Visual Web Developer Express 2010, we don't have the References folder built in. I saw this solution: https://stackoverflow.com/a/13035466/2178080 that suggests (but doesn't recommend) copying a dll to the application folder.

I'm a bit new to deploying with ASP and not sure how to include the System.Transactions library so the host can find the reference. Has anyone run into this issue?

Edit: We went with the route of copying the dll to the site along with the application. The steps to do this:

  1. Copy the System.Transactions.dll from the local system.
  2. Paste into the Bin folder.
  3. The objects referenced in this assembly must now use the fully qualified name.

As this solution is listed as not recommended, I am still open to other solutions.

Edit2: Grant and Chris helped me understand that I was working with a Web Site and not a Web Application. Grant helped with the specifics of the Web Site problem.

Community
  • 1
  • 1
user2178080
  • 57
  • 1
  • 6
  • 1
    Does the namespace `System.Transactions` even exist? If it does, did you add it to the References panel of the solution? – Cole Tobin Apr 25 '13 at 14:29
  • In Visual Web Developer, they don't show the References folder. I can go the site property pages and it shows the references with System.Transactions listed in there. It does seem like a manual step may be needed to copy the dll, but I'm not sure exactly where or how. – user2178080 Apr 25 '13 at 14:36
  • @user2178080 You should be able to set the build output type of the reference such that it is automatically copied from it's source with each build, using the Properties tab, instead of manually copying. Watch out for licence caveats with such deployment, though. – Grant Thomas Apr 25 '13 at 15:36
  • As it's an ASP.NET website (or is it an Application proper?) I can't see that you'll be able to do what I just said. One way, again, dependent on licence, would be to copy from the GAC to a ThirdParty folder in your solution root, and reference it from _there_, this should add it with an Auto-Update setting, meaning it will source the binary from that directory per build and output it to the bin directory. Those added from the GAC won't do this. – Grant Thomas Apr 25 '13 at 15:41

2 Answers2

9

Your problem is due to the published site is not bringing the System.Transactions.dll along with it, this points to "Copy Local" being set to False and thus the DLL not copying to the bin folder.

Go to References -> System.Transactions and make sure on the properties for this reference that "Copy Local" is set to True.

Chris Dixon
  • 9,147
  • 5
  • 36
  • 68
  • As suggested per my comment (as it's not strictly an answer, which is about to become evident (if it's a website and _not_ an 'application'): this would be desirable over manual copies but an ASP.NET website with references in the `bin` folder, this isn't supported. – Grant Thomas Apr 25 '13 at 15:38
  • He's using an ASP.NET Web Application in his question, which I use every day, and it's very much supported. – Chris Dixon Apr 25 '13 at 15:40
  • It turns out that I am using a Web Site, which explains most of these issues. I am looking at converting this to a Web Application but am wondering if it's worth it. When seeing this answer, it tipped me off that something just wasn't right. – user2178080 Apr 25 '13 at 16:28
  • Where is this "References" option? Is this in a menu somewhere? – Jimmy Jul 27 '18 at 12:41
0

Check the target framework in IIS, make sure it's set to the same version of .Net that you are compiling your code in. If you are using IIS 7+, which have Application Pools, make sure the pool the application is running on is the same version of .Net.

Paritosh
  • 4,243
  • 7
  • 47
  • 80
  • They both use the same target framework. The problem seems to be coming from the fact that we just use an FTP copy to upload and the reference doesn't make the copy. – user2178080 Apr 25 '13 at 15:20