问题
This is in an ASP.Net web application, with Visual Studio 2013. The solution is composed of several projects. I have code in a library project that has using System.Transactions
, and it's worked well for months.
Today I added the same using System.Transactions
in code in the web application project, and it fails with the error message below:
The type or namespace name 'Transactions' does not exist in the namespace 'System'
Here are a few things I've tried:
- Added a reference to
System.Transactions
. - Verified that the referenced dll file is the same in both projects.
- Changed the framework from 4 to 4.5 and back.
- Verified that all projects are using the same framework version.
- Cleaned and rebuilt the solution.
- Quit Visual Studio, deleted all files in AppData>Local>Temp, rebuilt.
- Restarted the PC.
So, the upshot is that using System.Transactions
works fine in one project but not another, even though both projects are in the same solution.
Any suggestions?
EDIT: Here's an oddity that's probably not any additional help, but here goes:
- When I build the project, there are no errors. That is, the
using System.Transactions
compiles just fine. - If I run application, it bombs and the error appears in browser window. The VS code window still shows no errors.
- If I edit the
using System.Transactions
or add code likevar x = System...
, the errors immediately appear in theusing System.Transactions
.
** EDIT:** This question was marked as duplicate. It isn't -- the proposed duplicate solved the question by browsing to the reference. I had already tried that and it didn't help. In my case, I had to use the "copy local" option.
回答1:
Refer to this Answer By Mark Hall
There is a Microsoft Connect entry posted for this. There is a comment that suggests that you can browse for it. The path given is:
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5\System.Transactions.dll
Just Add reference by browsing to this path
if this did not work, Go to References -> System.Transactions and make sure on the properties for this reference that "Copy Local" is set to True.
回答2:
usually System.Transactions is not part of your references, try to add it in your references by:
right click on your references if you are using Web Application or in your Project if you are using Web Site. find the System.Transactions in the .NET references. You should find the System.Transactions in your references.
来源:https://stackoverflow.com/questions/30248051/the-type-or-namespace-name-transactions-does-not-exist-in-the-namespace-syste