Unknown Exception During Build - visual-studio-2013

I'm getting an unexpected error when I (re)build the main project of my solution:
"Exception has been thrown by the target of an invocation." D:\MyApp\Db\Model.edmx
Db is a supporting project referenced by the main project. I created the .EDMX with a Model-First design.
I've looked at the detailed build output, but nothing is apparent as to what the cause and/or source of this is. There's no apparent way to find out what the exception actually is.
Nor does Google return anything for this error in the context of an .EDMX file.
How to go about finding out what's causing this, so I can fix it?
EDIT #1: I also get the error as a single MessageBox when I try to open the .EDMX for editing in Visual Studio. There's no hint about what the exception may be, nor where I might find more detail.
EDIT #2: I've been able to narrow it down to one of these four assemblies:
Db.dll (the project assembly)
EntityFramework.dll
EntityFramework.SqIServer.dll
EntityFramework.SqIServerCompact.dll
If I delete any one of the four in the project's \bin folder, I can open the .EDMX for editing.
Does anyone know how to trap the exception that's occurring, so I can go about fixing it?

I found the source of the exception—it's the SqlServerCe provider (or its configuration) that's installed by SQL Server CE & SQLite ToolBox. When I change the provider to SqlClient the exception disappears.
This is not impugn this excellent tool—there just appears to be a conflict between its latest version and VS2013.4.
EDIT:
I'm pleased to be able to retract my report; the problem didn't lie within the extension's scope.
The problem was that I hadn't installed the EF Tools for Visual Studio nor registered the DDEX provider. Details here.

Related

DB Project won't load in Visual Studio 2013

The error says:
Failed to create extension manager for the target platform 'Microsoft.Data.Tools.Schema.Sql.Sql120DatabaseSchemaProvider'.
My teammate created the DB Project, but when I pulled it down from source control it failed to create.
The solution is to get an update to the "SQL Server Data Tools". You apparently have an older version.
Look in Visual Studio 2013 under Tools-->Extentions and Updates. On the left pane from there, click on Updates. Hopefully you'll be able to find the update you need there.
(Alternatively, run a repair installation on "SQL Server Data Tools" under Windows' Control Panel-->Programs.)
I fixed this problem by lowering the required version of the tools. I'm not sure why they are installed on his machine and not on mine, but edit the dbproj file and change the requirement to a lower version, like this:
Original:
<SchemaVersion>2.0</SchemaVersion>
<ProjectVersion>4.1</ProjectVersion>
<ProjectGuid>{......}</ProjectGuid>
<DSP>Microsoft.Data.Tools.Schema.Sql.Sql120DatabaseSchemaProvider</DSP>
<OutputType>Database</OutputType>
<RootPath>
</RootPath>
Updated: (don't include the *'s)
<SchemaVersion>2.0</SchemaVersion>
<ProjectVersion>4.1</ProjectVersion>
<ProjectGuid>{......}</ProjectGuid>
**<DSP>Microsoft.Data.Tools.Schema.Sql.Sql110DatabaseSchemaProvider</DSP>**
<OutputType>Database</OutputType>
<RootPath>
</RootPath>
Had the same problem and tried the above solutions, though even creating a new project from scratch was getting the same error message. I was also getting "File exists" for some reason.
I found the following in the event viewer:
Description: The process was terminated due to an unhandled exception.
Exception Info: System.IO.IOException
at System.IO.__Error.WinIOError(Int32, System.String)
at System.IO.Path.InternalGetTempFileName(Boolean)
Cleared my temp directory and now the database projects are once again behaving. This is probably not a real common solution to this problem, but wanted to get the info out there in case it can help anyone else!
You can try these steps:
Try adding another database project in your solution.
Enter in the edit the DBProj File
Copy the DSP and use that one.
I was trying to move the proj from vs2013 to vs2012 and it worked for me. The provider was:
<DSP>Microsoft.Data.Tools.Schema.Sql.Sql110DatabaseSchemaProvider</DSP>
You can try the one above if you have VS2012.

What does VS project binding do?

What does Visual Studio's unbind | bind operation do to projects in a solution.suo file?
Microsoft provides instructions on How to: Bind or Unbind a Solution or Project, which happens to remedy the dreaded "Unspecified Error" that occurs at solution opening. This MSDN forum posting has a user stating they unbound and then re-bound their projects in order to solve that problem.
As I was experiencing the same "Unspecified Error" problem, I did some additional digging and found that the solution.suo file was the only likely candidate that had changed after I had resolved the issue.
I read this answer to an SO question about .suo files being effectively disposable and happened to be able to recreate the UE problem through a stale workspace I had laying around. So I went ahead and deleted the solution.suo file and opened the solution.sln file. Magically, my UE problem had gone away with that workspace too.
That led me to conclude unbind | bind has some sort of effect on the .suo file, but because of the files binary, proprietary structure I wasn't able to identify what's going on.
My Questions:
1. So what exactly does Visual Studio's unbind | bind operation do to projects in a solution.suo file?
2. Can anyone surmise what's causing these "Unspecified Errors" now that I've find the linkage to the .suo file?
Footnote 1: This MSDN article explains a little bit about .suo files, but doesn't really go into details.
Footnote 2: "Unspecified Error" on project / solution opening appears to be quite the bête noire as evidenced by here, various searches, and this old MS KB
Sure, the .suo file is where Visual Studio stores the state of the IDE. So that when you open a solution again later, everything restores the way you left it off. The most obviously visible effect is that windows restore in their original position and size. And yes, the binding of the solution to the specific source control server where you want the changes to be checked in could well be stored there as well, it is the logical place for it.
"Unspecified error" is a very generic COM error code named E_FAIL. Visual Studio uses a lot of COM code, the add-in system is entirely COM based. It is a lousy error because it doesn't mean anything more than "it didn't work, don't know why". Similar to returning false from a function. There's a programmer at Microsoft somewhere that could have done a better job reporting the problem. Maybe that wasn't so easy.
VS project binding stores which projects are managed by source control. It is saved in the .SLN file.
Unfortunately, the format in which it's save is hard for source control systems to merge. Therefore, the bindings often get corrupted, leading to erroneous "Projects have been added to source control" messages when loading the solution. The procedure to fix this is to delete that entire section from the .sln file, open in VS, and then re-bind the solution, which will create the section correctly.
BTW, the whole solution file format is quite awful for merging. It smells like VS6, and the source control section smells like SourceSafe. I wish they'd move to some MSBuild-based format, like they did with (almost all) project files.

Configuring ObjectDataSource: Exception has been thrown by the target of an invocation

In my project in Visual Studio 2010, I'm trying to add an Object Data Source which points to one to my business services, and to bind the datasource to a datagrid (or datalist, or whatever).
The problem is, after adding the ObjectDataSource from the toolbox, when I hit the "Configure Data Source" link to open the configuration wizard I get this error:
Error invoking Configure Data Source - Exception has been thrown by
the target of an invocation
This only happens in my project (i.e. if I create a blank project, ObjectDataSource configuration works properly).
Searching similar questions here in stackoverflow and on the internet I've read that this error is often related to a missing assembly. In fact, my project references several .dlls, and after checking time and again I just can't see what is missing. I also tried enhabling logging on Visual Studio, but it doesn't log anithing related to that error.
So: is there a way to get a more exhaustive error message from Visual Studio? Perhaps accessing the "inner exception" that fired the error, like you do when debugging your code?
And by the way: is there a way to configure "manually" ObjectDataSources without using the wizard?

Weird Visual Studio 2010 Behavior - not copying dlls to bin

I hope someone else has encountered this because its driving me batty.
I recently got a new laptop so I've been setting up my Visual Studio solutions (VS2010 with .NET 4.0) that I saved off my old machine. One of them is a simple console app that I use to simulate some things for testing. It references 2 assemblies that I have in another solution that I am working on now. This used to all work fine as expected but ever since moving to the new machine I get the dreaded "The type or namespace name 'YourAssembly' could not be found (are you missing a using directive or an assembly reference?" error message. The references are clearly shown in the Visual Studio but when the project builds it does not copy them to the bin directory which explains the message. Initially I was just referencing the dlls the way I would any 3rd party dll but I even tried removing that and including the project files in my solution and referencing them that way and still it fails. I've verified that the dlls have their 'Copy Local' property set to true and they do. Its really bizarre because the project references several other dlls that are just 3rd party assemblies (for example NLog, GData, etc) and those all copy over fine but not these two for some strange reason.
Here's one more piece of oddness. If I add some code to the console app that references my assemblies it says it can't find it. If I then re-add the assemblies to the references, the error disappears until I try to build it again and then it returns. Is this a VS bug or what? I've never seen this kind of odd behavior before.
thanks
One case that I have seen that caused the problems you are talking about:
Including references to dlls that are built in-house, linked to a specific version of the dll. Get a new copy of the dll (with a different version number) and the build breaks.
The solution in this case is to set the DLL reference property Specific Version to false. The version of the dll is ignored (in my case, it is safe to ignore it), and the build works properly.
I've also had weird errors like this where the NTFS permissions were set on the old file with an old login, but the new machine didn't like the old permissions.
Also, sometimes the old .sln or .csproj file refers to an odd file path that you can't seem to edit from within VStudio. Try opening those files with notepad and make sure the paths aren't broken. You can usually edit and save with fixed paths and things will work again.
Hans had the answer above but I was unable to find that post through searches so hopefully if you stumble upon this question I can save you several hours of frustration.
For some bizarre reason the 'Target Framework' was defaulting to ".NET Framework 4 - Client Profile" in the project properties. I double checked and it seems to do that whenever I create a new console app. It must be version related thing in VS because I hadn't encountered this issue previously in 2010.
To fix:
Right click on your project, choose properties
Under the main Application tab, set the Target Framework to be your framework of choice but NOT one of the 'Client Profile' options
Save and build as normal

Error "Metadata file '...\Release\project.dll' could not be found in Visual Studio"

Recently I started to get this message randomly:
Metadata file '...\Release\project.dll' could not be found in Visual Studio
I have a solution with several projects in it. The current build mode is Debug and all projects' configurations are set to Debug. But when I try to run the main project - sometimes it gives me a few errors, all of which are "Metadata file '...\Release\projectX.dll' could not be found" - and, look, it says about RELEASE folder, though current mode is Debug. Why? I tried to search for reference to "Release\projectX.dll" inside all solution files, and I found one in ResolveAssemblyReference.cache file.
I made a good search over the Internet and found a few people with a similar problem, but there was no solution, or at least no working solution.
I tried to delete references to those projects and read them, but in some time I start getting these errors again.
It seems like a bug. Why does it search for referenced projects in Release folders when I always use Debug mode?
PS. For those who met this problem: I couldn't solve it in an easy way. It disappeared only after I reinstalled Windows :(
Everyone is correct...try everything...(in order of a little to a lot of time wasted)
Do you have bad code? Fix that first.
Clean Solution & Restart Visual Studio
Remove / Add References
Check your build order w/ larger projects and verify
Manually rebuild sub-projects
Manually copy dlls between projects into associated bin folders
Go get some coffee, play some pinball and come back tomorrow...you may think of something else in the meanwhile.
I had the exact same problem. Big visual studio solution with 50+ projects.
All references were added as projects.
Project build order was correct (right click on project and select build order).
However when building some of the higher level projects the "root" project they depended on were not built.
The problem was that these projects were not selected to build under the current configuration (don't know how this happened).
To check this select "Configuration Manager" (Build menu) e check if the problematic projects are set to build.
When you say you deleted references to those projects and re-added them, how did you re-add them, exactly? Did you use the "Browse" tab in the "Add Reference" dialog in Visual Studio? Or, did you use the "Projects" tab (which lists neighboring projects in your solution)?
Edit: If you use the "Browse" tab, and manually add the reference to your .dll that is located in the /Release folder, then Visual Studio will always look for the .dll in that location, regardless of what mode you're currently in (Debug or Release).
If you removed the actual .dll file from the Release folder (either manually or by doing "Clean Solution"), then your reference will break because the .dll does not exist.
I'd suggest removing the reference to ProjectX.dll, and add it in again--but this time, use the "Projects" tab in the "Add Reference" dialog. When you add a reference this way, Visual Studio knows where to get the appropriate .dll. If you're in Debug mode, it will get it from the /Debug folder. If in Release mode, the /Release folder. Your build error should go away, and you also will no longer be (improperly) referencing a Release .dll while in Debug mode.
Well, my answer is not just the summary of all the solutions, but it offers more than that.
Section (1):
In general solutions:
I had 4 errors of this kind (‘metadata file could not be found’) along with 1 error saying 'Source File Could Not Be Opened (‘Unspecified error ‘)'.
I tried to get rid of ‘metadata file could not be found’ error. For that, I read many posts, blogs etc and found these solutions may be effective (summarizing them over here):
Restart VS and try building again.
Go to 'Solution Explorer'. Right click on Solution. Go to Properties. Go to 'Configuration Manager'. Check if the checkboxes under 'Build' are checked or not. If any or all of them are unchecked, then check them and try building again.
If the above solution(s) do not work, then follow sequence mentioned in step 2 above, and even if all the checkboxes are checked, uncheck them, check again and try to build again.
Build Order and Project Dependencies:
Go to 'Solution Explorer'. Right click on Solution. Go to 'Project Dependencies...'. You will see 2 tabs: 'Dependencies' and 'Build Order'. This build order is the one in which solution builds. Check the project dependencies and the build order to verify if some project (say 'project1') which is dependent on other (say 'project2') is trying to build before that one (project2). This might be the cause for the error.
Check the path of the missing .dll:
Check the path of the missing .dll. If the path contains space or any other invalid path character, remove it and try building again.
If this is the cause, then adjust the build order.
Section (2):
My particular case:
I tried all the steps above with various permutations and combinations with restarting VS few times. But, it did not help me.
So, I decided to get rid of other error I was coming across ('Source File Could Not Be Opened (‘Unspecified error ‘)').
I came across a blog:
http://www.anujvarma.com/tfs-errorsource-file-could-not-be-opened-unspecified-error/#comment-1539
I tried the steps mentioned in that blog and I got rid of the error 'Source File Could Not Be Opened (‘Unspecified error ‘)' and surprisingly I got rid of other errors (‘metadata file could not be found’) as well.
Section (3):
Moral of the story:
Try all solutions as mentioned in section (1) above (and any other solutions) for getting rid of the error. If nothing works out, as per the blog mentioned in section (2) above, delete the entries of all source files which are no longer present in the source control and the file system from your .csproj file.
I've had this problem before and the only way I've found to solve it is to run Clean Solution and then restart Visual Studio.
For me it's usually the target framework being off (4.5.2 instead of 4.6) If you fix the target framework of the project to match the target framework of the solution and build, a new .dll will be created.
Re-open Visual Studio as Administrator.
Most of the answares say that you need to remove the libraries of your solution, this is true but when you re-add the libraries the error will be shown again. You need to verify if all the libraries referenced have a compatible .net framework with the .net framework of your solution. Then fix all the errors in your code and rebuild the solution.
Did you check the Configuration manager settings? In the project settings dialog top right corner.
Sometimes it happens that between all the release entries a debug entry comes in.
If so, the auto dependency created by the dependency graph of the solution gets all confused.
I've also seen this error in solutions where I have multiple projects (usually netTiers projects where I've updated one or more of the sub-projects to target the 4.0 framework). It can be problematic to remove. Oftentimes it can be resolved, however, by first fixing all other errors in sub-projects (eg, any missing references), individually rebuilding those sub-projects, then removing/adding back any references to those sub-projects in Visual Studio. Personally, I've had little luck resolving this error by cleaning the solution alone.
We recently ran into this issue after upgrading to Office 2010 from Office 2007 - we had to manually change references in our project to version 14 of the Office Interops we use in some projects.
Hope that helps - took us a few days to figure it out.
In my case it was caused by two things (VS.2012):
1) One of the projects was configured for AnyCPU instead of x86
2) A project that was referenced had somehow the "Build" checkbox unchecked.
Do check your Build | Configuration Manager to get an overview of what is being built and for which platform. Also make sure you check it for both Debug & Release as they may have different settings.
In my case, I had some errors in my code. Visual Studio showed the error you had instead of the actual errors, like syntax errors or unknown class names. Try cleaning the solution and building project after project. This way you will discover the actual errors.
Again, this is just what cause the error for me.
I had this problem and took long while to figure it out. Problem came up when I removed projects from solution and replaced those with nuget packages.
Solution seemed to be fine but the .csproj file still contained those projects multiple times as reference.
Seems that VS does not clean that file appropriately. It was still referencing the removed projects under the hood. When manually removed the references from csproj file all works again! wohoo
This problem is due to pdb files or CodeContracts.
To resolve it:
Clean your output folder and rebuild the solution.
Re-Configure the CodeContracts or disable it for temporary build.
We have that problem quite often, but only with references to C++/CLI projects from C# projects. It's obviously a bug deep down in Visual Studio that Microsoft decided not to fix, because it's 'too complex' and they promised an overhaul of the C++ build system which is now targeted for Visual Studio 2010.
That was some time ago, and maybe the fix even went into Visual Studio 2008; I didn't follow up on it any more. However, our typical workaround was
Switch configuration
Restart Visual Studio
Build the solution
I had the same problem myself.
Visual Studio 2013 only told me that it couldn't reference to it, and it couldn't find the metadata. When I opened my solution (which has multiple projects in it) it said that I was using projects lower than the framework version of one of my projects.
So I switched everything to version 4.5, and it worked again.
I seem to recall having a similar problem a few months ago. I solved it temporarily by copying the referenced DLL to the Release folder, thus satisfying Visual Studio's expectations. Later, I discovered the reference to the Release DLL in my actual code. You should try doing a search through the entire project for \release\project.dll.
Also, I have noticed that Visual Studio unit test projects sometimes put a "DeploymentItem" attribute on each of the test methods pointing to your target DLL, and if you switch between Debug and Release, Visual Studio can get confused if the DLL is no longer in the expected location. In my experience, these attributes can be safely deleted if you didn't put them there yourself as part of a "single deployment" scenario.
I had this problem and it was due to an invalid method in the offending library (dll) that did not return a value, e.g.
public bool DoSomething()
{
//I never bothered putting code here....
}
When I commmented this out everything compiled :)
Sometimes VS2010 switches my configuration from Any CPU to Mixed Platforms. When this happens I get this error message.
To resolve it I switch back to Any CPU:
1. Right click on the solution and select properties.
2. Click on Configuration Properties and then the Configuration Manager... button.
3. Under Active solution platform select Any CPU
I find that this usually occurs to me when i still have a method declaration in an interface, which a class implements, but that i had later removed and had forgotten to remove it from the interface as well. I usually just save the entire solution every 30mins n then just revert back to an earlier version if i cant find the error.
I ended up deleting my references (I had added them properly using the projects tab, and they used to build just fine), hand editing my .csproj files and removing bizarre entries that didn't belong -- and setting my outputs for debug and release, x86 and x64 and any cpu to all be "\bin" -- I built it once, then re-added the reference (again, using the projects tab), and everything started working again for me. Didn't have to restart Visual Studio at all.
For me this was caused by the Build target having been rewritten to not output the dll. Removing this to fall back on the default Build target fixed the issue.
For me was to remove/delete entire .vs folder(that is an invisible one) and then:
- Build
- Rebuild
and done.
in my case i was working on a branch off master. so i checked out master branch, ran a build and then checked out my branch. It fixed the issue. If you already are on master, i suggest you check out previous commit and then build it.
It seems to happen when you checkout a solution with multiple projects that have references between them, and you haven't built it before. If you have references directly to the dlls, instead of referencing the project, you'll get this message.
You should always use the Projects tab in the Add Reference dialog to add a reference to a project in the same solution. This way, VS can know the correct order in which to build the solution
same happened to me today as described by Vidar.
I have a Build error in a Helper Library (which is referenced by other projects) and instead of telling me that there's an error in Helper Library, the compiler comes up with list of MetaFile-not-found type errors. After correcting the Build error in Helper Library, the MetaFile errors gone.
Is there any setting in VS to improve this?
I had the same problem. I noticed that my db context (EF4) that was located in the project dll wasn't recognize for some reason. I deleted it and created another one instead. and that solved it for me.
Had the same problem today.
My application, a Windows Forms applications, accidently had a reference to itself. Weird.
Once removed, the error went away.
The reference got added each time I dragged a user control, located in the Windows Forms project itself, to a form.
I had the same problem. Manually removing and adding the dlls did not help. ClassLibraries did not compile for all the projects and were missing in the ...\bin\Debug folder for the project [because I cleaned solution by mistake]. Since the class library did not compile that means there may be some errors somewhere in one of those sub projects.
Solution: Since my dlls were there for the ...\bin\Release folder, I tried to rebuild on Release mode and found an error on one line in one of the sub projects. Solving the error and rebuilding the solution got rid off the build error.

Resources