Dll created in TFS not work - c#

I tried to created a .dll in TFS using VS2010 and use the .dll in a new project.
However, it keep on returning an error message saying the entity point for the method cannot be found.
To see if there is some error in the code of the class library, I created another class library project but not in TFS this time. This totally works well. This one can be referenced by C# using "using".
However, the one created in TFS cannot be referenced.
I would like to ask, what's the difference between these two .dll I created and what can I do so that I can successfully reference the .dll I created in TFS.
Many thanks!

Are you sure the error didn't say "Entry Point Not Found"? I have seen this many times when a project is set to build in x86 format when it should be building in x64 or AnyCPU. Right-click on the solution and go to Properties. Click Configuration Properties. Find your project and look at the Platform column. AnyCPU is usually your safest bet.

Related

Excel Interop build errors with .NET 5

I am porting a .Net Framework 4.7.2 project to .NET 5 and have Excel.Interop build errors that Intellisense has no problem with. I have:
Created a new .NET WPF project
Update the TargetFramework property in the .csproj file from .netcore3.1 to net5.0-windows
Copied my classes over into the new project
Added a reference to the Excel 16.0 Object Library
Changed the Copy Local property of the Interop.Microsoft.Office.Interop.Excel dependency to Yes and changed the Embed Interop Types property to Yes as well
Started a build
The build fails with Interop errors like "'object' does not contain a definition for 'Value'" even though those errors in Intellisense go away after I update the Copy Local and Embed Interop Types properties.
Following the build, if I double-click on each of the build errors, the class file opens and Intellisense considers the error resolved: it disappears from the list and the red line under the code disappears as well.
I see Interop.Microsoft.Office.Interop.Excel in the project Dependencies --> COM expandable items in the Solution Explorer, but when I right click on the Solution, do Properties, and look at Project Dependencies for my project, nothing is listed. Is this a problem? Would a COM reference be listed in Solution Properties --> Project Dependencies?
I was under the impression that the Office Interop libraries would be compatible with .NET 5 and that I am setting things up correctly. Why is does Intellisense think things are fine but build errors result?
Things I've tried
Restarting Visual Studio and my computer
Removing the reference and re-adding it
Cleaning and rebuilding the solution
Deleting the bin and obj folders in the project

Version conflict in a Visual Studio copied project

I have a Visual Studio solution which is running fine. I have copied a few projects from this and put in a new solution. When i try to run in one of the calls it gives me an error that a dll is missing.
I confirmed the existence of the dll in the project which is holding the reference to this other project, on further inspection, i observed the version number of the dll in the error message is not matching the version number of the dll that i had copied.
What might have gone wrong in my copy the project?
Please let me know if my question is at very high level? I will put in required details as you may need.
i understand error.refer the follwing link and go through the comments ,u will definetly got the answer.
.Net picking wrong referenced assembly version
OK, i showed this error to my technical lead and here was his finding -
it was because of another project which was being referenced in my main project. This another project was having a reference of this dll too. This another project was of the version number which i was getting an error of.
My TL told me that since this another project was compiling of different version number, it was expecting my dll to be also of the same version.
Over here, i have used the term another project for convenience of understanding only. It is not "another project" but another dll instead which is internally referring to the dll which i was also using in my main project. It seemed that these dlls should both have been of same version for running correctly.
I found and copied this dll from my colleagues machine and referred it in my main project and got through with this problem.
To identify this dll also -
We ran the old code and new code and with help of ProcMon my TL concluded the version conflict of this another dll

Unable to add project reference in Visual Studio 2015

I previously asked a similar question regarding Visual Studio 2013 but now I'm running into the same problem with Visual Studio 2015 but it seems to work differently, which makes the previous answer not applicable to this question. This is my previous question: Visual Studio 2013 - How to debug a project within a solution
I'm attempting to add a project reference. I have a library I'm working on in a separate solution/project and a console application I want to use to test and debug the library.
I tried: Add Reference > Projects > Solution > Browse
But the open file dialog does not contain .sln files in the filter list and if I force it to display them by typing *.sln and then select the Solution I get:
"Please make sure the file is accessible and that it is a valid assembly or COM component."
What am I doing wrong? How do I properly add a Solution/Project reference?
For me issue was due to difference in Target framework. One was .NET Framework 4.5 and other was .NET Framework 4.5.2
Verify if the Target framework is same for your project and the project reference that you are trying add reference.
(Right click on project -> properties -> Application Tab(Target frame work))
Right click on your solution file in Solution Explorer window, click Add and select Existing Project...
Once the project is a part of the solution, you will be able to add project reference.
In case anyone else runs into this here is something that I found. I had almost the exact same issue in VS 2015. I created a console app and then a class library project but could not add a reference to the class library.
It turns out I didn't create a class library project as I had thought, but rather a class library (package) project. These are different things and I was unaware of what the (package) part meant when I selected it. This is for creating Nuget packages, apparently.
I'm not sure if this is something new to VS 2015 but I had not run across it before and it caused me some grief. The error message ('A reference to ClassLibrary1 could not be added') was totally worthless in trying to debug it.
You should add project to your solution first; after adding project to your solution, you can reference it.
To add an existing project to your solution:
Add reference menu:
Add references dialog:
In order to add a project reference, the project has to be part of the solution.
For me issue was due to a difference in the types of projects. One was a C# Windows forms project and the other project was a C# Universal Windows project.
The Windows Forms project couldn't reference the Universal Windows project. The error was "Unable to add a reference to project "XYZ".
It appears you can have a library shared between both types of projects by folloing this answer: What kind of class library works with both Universal and Winform projects?
I ended up having a different solution. I had three projects in the solution which referenced a NuGet package which was no longer available. I had the library locally but I was unable to add it. I found that because of the BUILD ORDER and DEPENDENCY of my projects, I had to add it to the project that was built first, then I could add it to the projects that were dependent on that project.
I had this problem today and I looked at the configuration manager for the solution. The projects had different platform settings. I made them both Any CPU and rebuilt. Then I could reference the project.

How to include source instead of a library in C# / Visual Studio?

I come from a long Java background and very new to C#. I was trying to run one of the starter kit applications from Windows phone and I am getting this error.
A first chance exception of type 'Newtonsoft.Json.JsonReaderException' occurred in Newtonsoft.Json.WindowsPhone.dll
I am finding it hard to debug this because I am directly referring to the dll file under References pointing to Newtonsoft.Json.WindowsPhone. In Java, I would have searched for the library and downloaded the source to step into the exact location during debugging.
If that is possible, how would I do it in C# (as in how would i refer the library source for my project to pick up at run-time)? I am using the Visual studio 2010 Express Edition as the IDE.
Download the third party library you are dealing with
Add this library's project into your solution
In your project, remove the reference to the 3rd party library
Add a project dependency into your project, make it depend on the 3rd party library project you have just added to your solution
Compile and run, happy debugging
My best guess is you should download last release of Json.NET, remove the compiled library from your project's references and add reference to the source code project. (Add Reference... > Projects > Browse...)
Once you have stopped your program in the debugger, you can use the modules window to load the symbols for Json.NET. Obviously, you need to have the symbols on your machine so you can browse to them.
Failing that, you can switch to a project reference and include Json.NET in your solution as Dan suggested.
The easiest way is to download their latest build then inside visual studio right click your solution and under add menu select existing project point to project file of the library and click open button. after that u will be able to set brakepoint wherever u want.

Visual Studio 2010 suddenly can't see namespace?

My C# WinForms solution has two projects.
A DLL which is the main project I'm working on, and an executable WinForms I call "Sandbox" so that I can compile/run/debug the DLL easily in one go.
I'm working in .Net 4.0 for both projects.
Everything was working fine until I added some seemingly innocent code, and a reference to System.Web in the DLL.
Now my Sandbox project can't see the namespace of the DLL project. I didn't change anything which I believe should have affected this.
If I delete the project reference to the DLL from the Sandbox references and re-add it, then the red underlines all disappear and the colour coding comes back for all my classes etc; but as as soon as I try to build the solution, the whole thing falls apart again.
When I right-click the DLL project in the Sandbox's references and view in object browser, I can see the namespace and all the stuff in there.
I have a feeling this might be some sort of bug?
Is this some sort of VS2010 bug? I had this same issue a few months ago and I could only fix it at the time by making a whole new project and re-importing my files. This time, however, I have a bajillion files and will only do that as a last resort!
Edit:
After panickedly going through and undoing all my changes, trying to find what caused the problems, it seems to be this line:
string url = "http://maps.google.com?q=" + HttpUtility.UrlEncode(address);
If I comment out this line, then I get no namespace errors and the project builds fine. I can't see anything wrong with this line though.
I'm ready to declare this a bug in VS2010, this has bitten way too many programmers already. The fix is easy: Project + Properties, Application tab, change Target Framework to ".NET Framework 4" instead of the Client Profile that is selected by default.
System.Web is not included in the client profile. Having this option in the first place is quite silly, the client profile is only 15% smaller than the full version of .NET 4.0. Having it selected by default is even sillier. But I digress.
UPDATE: mercifully this all got fixed in VS2012. Which no longer makes the client profile the default for a new project. And the client profile got retired completely in .NET 4.5, good riddance.
Check to make sure that both projects are using the non-client profile for their target framework (go to each project's properties to do this).
One possibility is that the target .NET Framework version of the class library is higher than that of the project.
I faced this problem, and I solved it by closing visual studio, reopening visual studio, cleaning and rebuilding the solution. This worked for me. On some other posts, I have read the replies and most of users solved the problem by following this way.
Try building only the project with the Sandbox dll first independently.
Then point your executable project to the required dll and ensure copy local is set to true. in reference settings.
Tthen build the executable project.
Changing the target framework from the ".NET Framweork 4 Client Profile" to ".NET Framework 4" worked for me with a similar problem. I agree that the client profile doesn't seem to have much of an advantage to using it. I seem to get nailed with weird errors that I hunt for until I remember that Visual Studio defaults to the client profile. I guess the moral of the story when getting an error is: if "Rebuild Solution" doesn't work, check the Target framework...
If you tried already doing the Framework change, and still not worked, I hope this works for you (as it did for me): Simply add the necessary references from within your projects. Very obvious but I was doing it wrong until I found what was the issue.
I just had this issue and it turned out to be I had multiple namespaces being used that had the same object name (i.e. business objects had the same names as mvc models);
Fully qualifying the names fixed the issue for me.

Categories

Resources