Visual Studio loses reference when attempting to build - c#

I started using Thrift about a week ago. I got the latest source from SVN and built the C# library (Thrift.dll). I used the library to prototype a TCP client/server with the data types that my team will be using. This worked with no problem, I just followed the example code in the SVN repo.
Yesterday, I wanted to run the same test but over HTTP instead. I searched around online some and found out that from the time I got the code last week until yesterday patch "THRIFT-322" https://issues.apache.org/jira/browse/THRIFT-322
Was applied to the trunk. So I updated my thrift source from SVN and saw the new THttpHandler class. I rebuilt the Thrift.dll so I can use the THttpHandler class but now whenever I reference the new dll Visual Studio 2010 gives me an error at compile time: "The type or namespace "Thrift" could not be found (are you missing a using directive or an assembly reference?)". When I replace the reference with the old Thrift.dll that I have I do not get this error.
I can't figure out what I'm doing wrong, I just recompiled the Thrift.dll from the SVN source and I can no longer link to the Thrift.dll. When I first add the reference it seems like it's going to work fine. Visual Studio gives me the correct intellisense, etc. Once I try to build it's like there is no longer a reference to the Thrift.dll. Any ideas?
I also submitted this to the Thrift Users Mailing List, I just thought maybe this was more general and someone here may be able to help.
Thanks,
-Sean

Since you mentioned using VS 2010... I have seen this error/behavior sometimes when I am compiling a .NET 4.0 project and my target framework for the project is set to ".NET Framework 4.0 Client Profile" instead of ".NET Framework 4.0". So you might want to check that and see if it helps.

I had a similar problem I had to switch from '.NET Framework 4.0 Client Profile' to '.NET Framework 4.0' and it worked because a referenced dll is compiled using the '.NET Framework 4.0'

One Suggestion I have is to check for a file with 'refresh' in the extension E.g. Thrift.dll.refresh or something similar. This file is usually added on adding a refernce. Try removing this file, replace the dll and try builtign and running again.

Related

Oracle Managed Data Access DLL upgrading to latest version causes compile errors

When I upgraded Oracle.ManagedDatabaseAccess.dll from v. 4.122.18.3 to v. 4.122.21.1 there are several compile errors, specifically:
error CS0246: The type or namespace name 'Oracle' could not be found (are you missing a using directive or an assembly reference?)
The reference has been added. I initially used a version-specific folder, and thinking this could cause some sort of problem, I moved it to the exact same folder where the older DLL had been successfully referenced, and there was still the problem.
This is somewhat like Similar Oracle problem, except that the linked post appears to be about Oracle.DataAccess.DLL whereas this is the managed version, Oracle.ManagedDataAcess.dll
I also have tried cleaning and "rebuild all" as well as unloading the problematic project in the solution and reloading it also, and neither helps.
As far as I can discern, both DLL's are 32-bit.
I am using Visual Studio 2019, a C#, asp.net context, and since the other Oracle.ManagedDataAccess.dll worked without special usage of a "register DLL" procedure, I'm not certain if that is needed or will help.
Is there any help for this situation?
Turns out that I needed to use .net Version 4.6.2. This locally built on my machine and everything worked. We are not ready for this so I reverted to the previous DLL, but thanks. Also, when changing .net versions, one sometimes has to load/unload projects, restart Visual studio, and make sure the saves of the project file actually "take".
Perhaps this Question and Answer will help someone else, someday.

Can't access Microsoft.Xrm namespace

I've downloaded CRM Dynamics SDK and keep it in a local directory. In my code, I'm using EntityCollection (amongst other classes related to Xrm namespace), which means that I need to add using Microsoft.Xrm.Sdk;.
The problem is that during compilation I get errors saying that:
The type or namespace name 'Xrm' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)
So, I double check that the reference is made and, very accurately, I see that microsoft.xrm.sdk indeed is in my list. Just to be sure, I've removed it and added it again by pointing to the DLL with the same name. To no avail, though... The flabbergasting thing is that my colleague uses the same code and it compiles on his machine (the only difference being that he's on Win 7 and I'm on Win 8).
How do we kill this problem?
Double check in your project settings to see which Target Framework you are using. If it is .NET Framework 4 Client Profile try changing it to .NET Framework 4.
I received this when replacing my crm 2013 dlls with the new 2015 ones.
None of the above solutions worked for me.
But what eventually led me on the right track was this warning (it was listed as a warning below the namespace errors):
The primary reference "Microsoft.Xrm.Client, Version=5.0.9689.2166,
Culture=neutral, PublicKeyToken=31bf3856ad364e35,
processorArchitecture=MSIL" could not be resolved because it was built
against the ".NETFramework,Version=v4.5.2" framework. This is a higher
version than the currently targeted framework
".NETFramework,Version=v4.5.1"
And when I checked I only had .Net 4.5.1 installed so after installing .Net 4.5.2 Developper pack and switching the target framework of my projects to this everything worked again.
The regular 4.5.2 update is not enough to get this version of .net in VS, you need the developper pack
Source: http://www.syntaxwarriors.com/2015/using-crm-2015-sdk-gives-error-that-xrm-does-not-exist-in-the-namespace/
I had my framework already set to .NET Framework 4 therefore solution of switching between 4 Client profile and regular 4 did not apply. A trick I did was changing .NET Framework into 3.5 and then back to 4.0. I hope this will help some people.
Thx #Jason Lattimer. Your answer gave me a clue how to solve my problem.
Good luck CRM developers!
This may not match this specific problem, but I'll add this as something to check for others in case Google directs them here like it did for me.
In my case, I was getting a lot of errors like, "error CS0234: The type or namespace name 'Client' does not exist in the namespace 'Microsoft.Xrm'".
Adding the "Microsoft.CrmSdk.Extensions" NuGet package fixed my compilation issues.
After changing to .NET Framework 4 and changing .NET Framework into 3.5 and then back to 4.0, my poject was still not working.
It didn't work when I selected the option given by the "add Reference" window.
What worked for me was to click on the browse button in the "add Reference" window and look for the Microsoft.Xrm.Sdk.dll file
I had .NET 4.0 as my target framework and I had this compiler error. I tried changing it back to 3.5 and then back to 4.0 and that didn't fix it.
What did fix the problem for me was deleting the bin, obj and tools folders in my project directory. I don't understand the details of why this worked, but it worked for me.
I had this error and in my case, after trying all the above solutions and others on the web with no success, finally I came to a solution.
The problem was in the version of CRM SDK that I was using: 2015 (donĀ“t wanna know why!).
Downloaded CRM 2013 SDK version, changed the assembly references to that version and the problem was gone.
Reason for it is CRM 2015 SDK was built on .Net 4.5.2 Framework and the Visual studio does not support 4.5.2.
Just download .Net Framework 4.5.2
Goto Project Properties and change the framework.
I was having the same issue with my CRM 2011 Plugin. In my case none of the above solution worked.
In my code I am using early bound class. When generating this class file i was using following line along with other settings which was causing the error.
/codeCustomization:"Microsoft.Xrm.Client.CodeGeneration.CodeCustomization, Microsoft.Xrm.Client.CodeGeneration"
Once I added this new class file without codeCustomization, it removed all errors.
As mentioned before,
Reason for it is CRM 2015 SDK was built on .Net 4.5.2 Framework and
the Visual studio does not support 4.5.2.
Just download .Net Framework 4.5.2 Goto Project Properties and change
the framework.
Alternate way could be to replace Microsoft.Xrm.Sdk.dll with file from older CRM SDK. I use VS2010, and CRM 2011 SDK file solved all compiler errors.
P.S. Switching project to .NET 3.5 and back to 4.0 did not helped
Updating NuGet Package helped me to solve the problem

Linq not found after downgrading to .net 3.5

We recently tried to upgrade our software to .net 4.0. We ran into a small snag and rather than spend the time to try to track everything down we decided to revert back to .net 3.5.
We have encountered a few issues like .resx files not properly reverting, but they have been fixed. The final problem we have encountered is a few projects are not building via command line now (everything was before). The error in all cases is as follows.
The type or namespace name 'Linq' does not exist in the namespace 'System' (are you missing an assembly reference?)
We use Visual Studio 2010, msbuild for the command line builds, every project has been changed to a framework of 3.5. The projects will still build in the IDE, but it is fairly time consuming for us to build them all by hand, rather than by our automated script.
It would also be worth noting that all the projects that aren't building are web projects. Within the web.config I don't see a single version=4.0.0.0 reference.
CodesInChaos was partially right. While the UI showed a reference to System.Core, there was no actual reference in the .csproj file. This had to be added in manually. This explains why the UI would build, but the command line wouldn't.

Project reference not working in VisualStudio2010

I've got a Solution with lots of projects and all but one of them is behaving. The one that is not working is a ConsoleApplication, and it relies on C# Class Library project. I've added a reference to the library project, and add the namespace (which I've checked is correct), but everywhere I reference the classes in my library, I get:
The type or namespace 'MyClass' could not be found (are you missing a using directive or an assembly reference?).
The library project is building successfully (I can see the DLLs appear in the bin folder) and I've tried a project reference, and also a reference to the DLL itself. Neither works.
Also, all projects are set to build with a platform target of 'Any CPU'.
I've tried pretty much every suggestion I've come across on forums with no success. Can anyone shed some light on what's going wrong?
Thanks
This solved the problem:
The console application had a Target framework of .NET Framework 4 Client Profile, whereas the library just had .NET Framework 4. I set the console app to .NET Framework 4 and it all builds perfectly.
My bet is on a framework mismatch between your library and you app...
Check if your library is not building with a superior version than you app, or if your app is building with a Client profile flavor
It is probably that one of your DLLs references some part of the .net framework that is not referenced in your console application. For example if one of your class library projects has asp.net server controls in and references System.Web, but your console application does not reference System.Web it will not build and you will get that error. But it is not obvious because the DLLs referenced are stored in the GAC so they would never appear in your bin folder.
I had to simply restart visual studio for reference to work but make sure you have reference added in .csproj file.
If you still experience the issue, make sure the class you're referencing is public and that Asp.net core Framework version match.
Sounds weird,
Have you tried to remove the reference of the project and add it again? Check if your console app has got all the right references.
You could also inspect the .csproj file and see if everything is correct in there.
Just Check that you "Class Library" project has classes in it or if it is a data access layer project which include only a .edmx Model check the Model designer is found and it generates fine.
Good Luck
I worked with syncing the framework, but still, it was giving issue.
So I tried another way.
Right-click on the dependency, and select Add project reference. I added the required project then the error was gone.

Can't find System.Workflow assembly in .NET. How do I get it?

I've installed a complete SharePoint Server (MOSS) 2007 on my dev box + the latest Visual Studio (SP1) + the latest full Windows SDK. According to the Windows Workflow Foundation page http://msdn.microsoft.com/en-us/netframework/dd980558.aspx, that is all I should need to do to be able program against the .NET Workflow APIs.
And yet, all of the projects I build from the standard Workflow templates refer to the assembly System.Workflow and VS complains that that assembly isn't available. I've searched around on my hard drive, and I can't find a file for that assembly anywhere obvious on my disk.
I do find some files that look like they might be that assembly, but they're buried down in wacky places below particular applications like they are runtime support for that app. They don't seem to be what I'm supposed to point VS at.
Can anyone tell me how to fix this problem? Do I need to install something else that I have yet to come across? Are these assemblies already on my system and I just need to know how to point VS at them? I'm stumped.
BTW: I was going to try uninstalling and reinstalling VS, but the installer fails with some very cryptic error message when I try to uninstall.
TIA for any help, and Happy Holidays to all!!!
I did a Repair using the .NET 3.5 SP1 SDK distributable, and I believe that this solved the problem. I thought at first that it didn't (as I say in prior comments) because I was looking for the files to show up in the v3.5 assembly directory. The missing files actually go in the v3.0 assembly directory. I later brought up one of the sample projects in VC and noticed that the symbols were now resolving, and sure enough, the missing .dll files were now present.
So I guess that the .NET SDK installer that ships with VS somehow didn't install these .dll files. It took doing a Repair on the SDK to fix the problem.
I'm a happy camper now!
In addition to change the target framework to 4.0, you also need to:
Add a reference to System.Workflow.Runtime
Add a reference to System.Workflow.ComponentModel
There's no assembly named System.Workflow in .NET 3.x: the WF assemblies (in 3.x) are:
System.Workflow.Runtime
System.Workflow.ComponentModel
System.Workflow.Activities
System.WorkflowServices (3.5)
You should be able to find all these assemblies in the GAC, and reference them via the Add Reference dialog, .NET tab.
It's possible System.Workflow is a (badly named) SharePoint-specific DLL, in which case, sorry, the above won't help... try the SharePoint install directory or SharePoint SDK install directory. Are the project templates you're using SharePoint templates, or the ones from File > New Project > Visual C# > Workflow?
I have a same problem, and solved it. The reason is your project's target .net framework not include this assembly (it's maybe .net 3.5 client profile or 4.0 client profile). The solution is very simple: set the target framework of your project to .NET Framework 3.5 or 4.0.
It work for me.
Please find it in C:/Windows/Assembly/GAC_MSIL
All the DLLs are Present there..
Also If U donot Find it then do the Following
Right Click Project->Application->Target Framework-> .Net Framework 4.0
It should show Up then.

Categories

Resources