简体   繁体   中英

The type or namespace name 'Transactions' does not exist in the namespace 'System' (are you missing an assembly reference?) - C# ASP.NET

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.

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 .

检查IIS中的目标框架,确保它设置为您正在编译代码的.Net版本。如果您使用的是具有应用程序池的IIS 7+,请确保运行应用程序的池是相同版本的.Net。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM