.Net Project Build Issues - c#

I have a project (1 of 41) that will not load in Visual Studio 2012. I have inherited the solution and am attempting to get the environment spun up. There was an error stating that SQLServer.targets could not be found so I copied the file from my 3.5 folder to the 4.0 folder. Now, I am receiving the following error when attempting to reload the project:
error : Unable to cast object of type 'Microsoft.VisualStudio.Data.Tools.Package.Project.DatabaseFileNode' to type 'Microsoft.VisualStudio.Data.Tools.Package.Project.Internal.FolderNode'.
Any thoughts? I feel like I am spinning my wheels at this point. Thank you.

I had the same issue converting a class project that contained CLR stored procs for SQL Server. The VS 2012 conversion attempted to convert this to a sqlproj, but failed. Rather than try to track down the source of the problem, I removed the project from the solution, added a SQL Server Database Project, then dropped my code files into that new project.

Related

Website reference and objects code errors

I have a project which is a website working with SQL database. It is not my project but it is my website and I finally managed to get the source code from the coder. Long story....
I have loaded the project in VS2012 and managed to get the third party component Telerik and to sort out initial problems.
Now I am stuck with a series of errors related to something I do not understand how to solve. Please look at the picture:
I think it has something to do with the framework. It was developed in VS 2005 and framework 2. I am now in VS 2012 and framework 4 but I may be wrong. Please can you give me a direction on how to solve these errors?
Error 1 the name 'errlbl' does not exist in the actual contest. C:\Users\Pink\Documents\Visual Studio 2012\Projects\Stadler_new\login.aspx.cs
Error 2 the name 'RadMenu1' does not exist in the actual contest. C:\Users\Pink\Documents\Visual Studio 2012\Projects\Stadler_new\projects.aspx.cs
Errore 15 the name 'Button2' does not exist in the actual contest. C:\Users\Pink\Documents\Visual Studio 2012\Projects\Stadler_new\Search.aspx.cs
and so on.....

Entity Framework 4 issue

Using .NET Web API (.NET 4, EF 4) and I'm getting some strange errors when debugging and really can't figure what is going on.
Say in the DocumentRepository I have this constructor:
public DocumentRepository(DocPortalContext db)
{
this._db = db;
}
If I debug and hover over _db and drill into the items in the popup window I'm coming across the following errors:
System.Data.Entity.Infrastructure.IObjectContextAdapter.ObjectContext = 'System.Data.Entity.DbContext' does not contain a definition for 'System' and no extension method 'System' accepting a first argument of type 'System.Data.Entity.DbContext' could be found (are you missing a using directive or an assembly reference?)
and
System.Collections.Generic.ICollection>.IsReadOnly = 'System.Collections.Generic.Dictionary' does not contain a definition for 'System' and no extension method 'System' accepting a first argument of type 'System.Collections.Generic.Dictionary
No exceptions are being caught.
If I put a break point on this line in a repository method - return _db.Documents.AsQueryable(); - and hover over Document I get the following error:
System.Linq.IQueryable.Provider = 'System.Data.Entity.Infrastructure.DbQuery' does not contain a definition for 'System' and no extension method 'System' accepting a first argument of type 'System.Data.Entity.Infrastructure.DbQuery' could be f...
Some help would be much appreciated.
Additional information:
Drilling into _db in the following way gives message quoted at the end:
base(System.Data.Entity.DbContext) -> Internal Context -> _appConfig -> and finally Default Connection Factory has the following error beside it "The function evaluated requires all threads to run."
More information as per my comment:
This isn't really related to the question, but it has me thinking there could be something wrong with my install of .NET or VS - I don't know enough about the pipework to make that call, maybe one of you can. Anyway, I can browse to a URI in my WebAPI project and get JSON returned in the browser. When I try to consume the URI in my Website project, I get this in my browser: Could not find file 'C:\Program Files (x86)\IIS Express\System.Net.Http.StreamContent'. which is also caught as an exception.
By default EF 4 generates proxy classes on the fly that inherit from your POCO classes or your model first classes. That is most likely why you get these errors on runtime. The odd things is that all required usings should be included.
Are you sure you reference System in your POCO classes (presuming you have POCO classes)?
Do all projects in your solution have the same .NET version setup in project's properties?
Do those versions agree with the version on the MSDN describing the missing classes?
Try registering your entity-framework dll and sql-server dll in global assembly cache using gacutil.exe from visual studio command prompt
I had come across this issue recently on a small sample application where we just included nuget packages and created some data layer objects. This is what we did and it solved the issue
Make sure temp folders for .net are clean . usually in asp.net temporary files in windows directory.
Make sure your visual studio is upto date and not requiring a restart due to nuget reinstall. Not sure if it solved or did help but i checked this as well and restarted vs.
Clean the projects and made sure that dlls are present. if you are using some webmatrix dll for asp.net simple membership make sure you have selected to copy it locally. This was one issue when we were seeding data for roles and members for mvc4 simple membership use but may not be the case for your project.
We also checked that in web projects the configuration for ef corresponds to proper version of ef.
Build the solution and run it after a vs 2012 restart and it worked fine. Now I dont know exactly which of these things helped in resolving this issue but doing all 4 worked in one case.
Just thought to share if it helps.
These look like issues relating to an incompatibility between your project's target .Net version and the build version of the assembly you're referencing.
In this instance, you should make sure that the assembly you are referencing is less than or equal to your project's target .Net Framework version.
I have seen this message numerous times. 9 times out of ten, this means that there is a likely problem with the App.config file. Usually, it is just missing. In other words, for every project folder you have referencing the Entity Model you need to place a copy of that App.config file within it. If they are already there, then delete the App.config file that partners the edmx file, and recompile the Entity Model separately to regenerate it. (DON'T DELETE THE EDMX FILE or THE DESIGNER CLASS) Then you have to replace all the App.config's again. Yes, it sucks!!! Sometimes, LinqPad is great for checking this issue too. You can reference the dll file in LinqPad and attempt to run queries giving you the same error message letting you know that the problem is not just Visual Studio.
Hope this helps...Good Luck!!!!
How are you implementing your repository? Seems to me that maybe the problem is that your application is running on a different thread than your repository and that might be the answer for the "The function evaluated requires all threads to run." message.

Strange exception suddenly appears when trying to install a setup project, need help big time

Using Visual Studio 2010 to build a setup project that installs a Windows Forms application .Net 4.0 C#. It has worked fine for ages but now when I'm trying to install the finished setup file, I'm getting this error message:
Error 1001. Unable to get installed types in the "Path" assembly. -->
Unable to load one or more of the requested types. Retrieve the
LoaderExceptions property for more information.
I have been searching for answers for over 4 hours now without finding anything. This problem just came without me doing anything. Last time I build the install file was like 2 weeks ago and there was NO problem at all. I haven't deleted any reference or any code that have anything to do with the setup project.
How could this problem appear from nothing and more important, how do I fix it?
Based on the error message in your second comment, it appears that your SysDir.exe assembly has been added as a Custom Action with the InstallerClass property set to true, but either no installer classes could be found in the exe or the exe could not be loaded due to missing dependencies.
You can see the list of Custom Actions by right-clicking on the installer project, selecting View and then Custom Actions.
If your exe does not can an installer class, then you can remove it from the list of custom actions.
If it does contain an installer class, then the issue is going to be missing dependencies. If fuslogvw doesn't work for you (it has always helped resolve this kind of issue for us), you can carefully review the list of references in the exe's project and compare them to what is listed in the installer project.
The other trick that we use is to examine the install directory while the error message is displayed on the screen. We can often see that DLLs are missing by doing this, usually because the path was entered incorrectly in the DLL entry within the installer project or because a condition was set incorrectly.
Have the same error today. For me it was the project type of the class library.
I noticed that the pucture on the guide I was following had selected Class Library (.NET Framework) instead of just Class Library.
Creating the correct project type fixed the error.
https://nhvu1988.com/posts/how-to-create-msi-installer-using-vs-installer/

Could not load System.Data.SqlServerCe.Entity.dll (Yet it's there)

I have a silverlight application. The server app has an SQL Server CE 4 .sdf in App_Data, and an ADO.NET model generated from it.
If I try to Add->New Item->Domain Service Class, I get the error:
Schema specified is not valid. Errors:
Models.TasksDatabaseMode.ssdl(2,98): error (0004): Could not load
System.Data.SqlServerCe.Entity.dll. Reinstall SQL Server Compact.
However, I installed RIAServices.EntityFramework and EntityFramework.SqlServerCompact via NuGet, which has successfully downloaded this .dll to /packages, and the file has been copied out into the /bin folder. So I have no idea where it is apparently looking for this .dll, if not there.
Perhaps related, I was earlier attempting to have the database generated code-first. However, the Domain Context Wizard was also failing, but with an error about an index being out of bounds. With a manually written service, the build was failing with a MetadataWorkspace error, about which I couldn't find any information.
Does installing the runtime directly (http://www.microsoft.com/en-us/download/details.aspx?id=17876) fix the issue?
Also, what version of the binary are you using? I suspect that you may have the private version (4.0.0.1) and generation is expecting the machine version (4.0.0.0)

The referenced project x does not exists

Hej All,
I upgraded my solutions of a project from vs2008 to vs2010.
But right now I have a weird problem. I reference a project in multiple solutions (3 solutions)
In 2 of those solutions the referencing goes wrong.
I am able to add the reference (project reference) but when I build I got the warning the referenced project x does not exists. And errors that I have to add an reference.
I already deleted and added the project again, same with the references but no result.
Does anybody have any idea?
Greetz,
Jonathan
I had the a similar problem and the other solutions didn't help. What worked for me was opening the project file in a text editor. There were duplicate references to a library, one as a project reference and one as a dll reference. I deleted both. Then I opened the solution in Visual Studio, and re-added the reference as a project reference. Only one reference got added and I stopped getting the warning.
Make sure your project is not using the ".NET Framework 4 Client Profile" as target framework, this is the most common source of these problems.
You can check this in the project properties under Target Framework.
From MSDN:
If you are targeting the .NET
Framework 4 Client Profile, you cannot
reference an assembly that is not in
the .NET Framework 4 Client Profile.
Instead you must target the .NET
Framework 4. For more information, see
Troubleshooting .NET Framework
Targeting Errors.
I was experiencing the very same issue although I was correctly referencing .NET 3.5 in all the projects migrated from VS 2008 to VS 2010 (all references to System assemblies were using a runtime version v2.0).
Weird however, the error only occured if my solution (and the projects in this solution's subfolders) were located in certain path... I could "solve" the problem by moving the projects or renaming the projects (only the project file, not the output binaries) ?!
Double clicking the reference in the project opened correctly the Object Browser where I could find all the artifacts defined in the referenced project !
I did start to delete everything from the project (classes, resources, references, etc...). At the end, I had only two projects (A referencing B) without any other references and with only one empty class in each. I still had the message "referenced project '..\B\B.csproj' does not exist.". Suddenly, trying to copy the source to another PC and next back into the original path on my machine (kind of black magic to solve the problem), I did get the message "Cannot copy. Resulting file name is too long".
Wierd² !!! I did delete every thing on my PC and did copy back again the sources from the other PC. It passed successfully ! I did recopy again back from the other PC (overwriting now the existing local copy) and again I got the message "Cannot copy. Resulting file name is too long". So the problem occurred only when overwriting existing files.
I found that the error occurred only if the existing file was "readonly". Removing the flag readonly solved this issue. However, this error was the sign of something possibly at the root cause of my initial issue: "referenced project '..\B\B.csproj' does not exist."
So, I decided to check if the project path length was the issue by renaming one of the folder but not changing the total length! The error still occurred (reference not found).
Next (I knwow, you already think I am crazy or stupid. But all those steps were validated by various colleagues), I did copy the solution in a new folder (with a longer path). Surprise, the error did not occurred anymore !!!
But moving the solution back to a folder with the same length (possibly another name) was reintroducing the error (after a "Clean" of the solution otherwise the meta in obj helped to solved the reference).
I was also able to reproduce this by renaming the project file B instead of a folder in the path. A longer or shorter project filename was solving this issue.
The length of the project filepath is "195" :
D:\TFS_Builds\5\XXXX 1.1\Release 1.11\Sources\Release 1.11\Exception Repository\XXXXXX.Framework.ExceptionHandling.Repository.ServiceHost\XXXXXX.Framework.ExceptionHandling.Repository.ServiceHost
Also, as I can be very creative when trying to identify the root cause of a problem, I did create the very same path on C:\ and put the solution in there... Same error occurred.
I never found (until now) the reason of this and have posted a question on MSDN :http://social.msdn.microsoft.com/Forums/en/msbuild/thread/f0eb6aed-5854-4678-9546-09c1a7705e30
Here is what fixed my problem:
I had a refference to a project named "Utilities.Proxy3.5", which would give me a the following warning:
"The referenced project
'..\..\Utilities.Proxy3.5\Utilities.Proxy3.5.csproj' does not exist."
Renaming the project folder and the project files to "Utilities.Proxy35" and re-adding the reference solved the problem. Note: I have only removed a dot between the numbers 3 and 5.
I hope this will help someone.
I had the same issue.
What solved it for me was that i opened each of the reference projects on its own first. VS asks for a permission to fix some of the files. Allow it to do so.
Then open the top project and it will work.
Apparently it was issues with the version of VS that created the original project.
Good luck
Check the lengths of the following:
The path of the referencing project's directory
The relative path to the project it references
If those paths add up to exactly 259 characters, you will experience a bug in the .NET implementation of Path.GetFullPath that will cause VisualStudio 2010 to behave as if the referenced project does not exist.

Categories

Resources