Enable-Migrations causes project failed to build - wpf

I have created a sample WPF project, worked fine.
I added a MVVMLight project, made it a default startup project, and ran fine.
Now I added a class library project, and added an ADO.NET data model with "Code First From Database", and selected relevant tables, that gave me a good collection of entity classes.
I thought this way, I can keep my data model seperate from presentation and businesss logic layers, plus add additional target plateforms if needed and take the advantage of SoC.
So far so good.
Now I want to enable Migrations on my data layer only. I fired up Nuget console, selected dataLayer project in the "Default Project" drop down. Issued Enable-Migrations command and very first error I got was
"No connection string named 'dpFinDataModel' could be found in the application config file."
Now I modified Startup project - i.e. Mvvm project's App.Config to add App.Config details from DataLayer project.
Tried to rerun "Enable-Migrations", and following error occured:
PM> Enable-Migrations
The project 'dpFinMvvm' failed to build.
Am I doing something wrong here?
Will this approach work?
Thanks for all your help.
-DP

1) PM> Enable-Migrations would get an error if your project itself contains errors.
Try going through your code such as in debug mode and check if you have any build errors then try.
2) And for your config file error you may have not referenced it properly, try this tutorial to solve your issue.
http://www.asp.net/mvc/overview/getting-started/getting-started-with-ef-using-mvc/creating-a-more-complex-data-model-for-an-asp-net-mvc-application

Related

"ERROR: General failure building project output groups" while creating Set Up project in Visual Studio 2019

I made a Windows Form App for borehole heat exchangers simulation, consisting only of one Form. When trying to build a set up project to install the app, I constantly get an error in the building. Message appears like below, and 4 times each message. All this is using Visual Studio 2019 updated.
ERROR: General failure building project output groups
ERROR: Unrecoverable build error - 0x80004005
I checked that every image used in the app are in the source file, that I have done the building in the right order, but every time I create a project output, no .xml file appears.
Although I think it should be not an issue, the program also created a Form1.resx file that sends a message (not an error, neither a warning) Object reference not set to an instance of an object. I donĀ“t remember creating such thing. I tried to erase it and almost got my app deleted.
Does anybody now what can be the problem and how to fix it?
Mainly my process consisted in building classes that represent different modellings of a borehole heat exchanger. I then made the program build an "borehole" object of the certain class you choose in a ComboBox. I had no fundamentals whatsoever in coding so maybe this is not the way I should do that, maybe it shouldn't be classes. The app works perfectly on debugging mode.
Public Class Modelo2D
Inherits ModeloNTU
Public ReadOnly Property Calor2D As Double
Is there a problem in this?

Why do I keep getting 'Assembly must be specified for XAML files that are not part of a project' errors in a local project?

To start with, I would like to stress that I do know how to define XML Namespaces correctly in my XAML files. This repeated error is not caused by an mistake in my code. The problem does not stop my project from being built successfully, or running and the mentioned Converter class works perfectly.
When I build the project, the errors disappear. However, the designer show the familiar error message:
When I click on the 'Reload the designer' link, the errors return. The worst part of this problem is that I lose all Intellisense on these views.
The error highlights these namespaces:
But you can clearly see that they have been declared correctly:
I'm sure that I have found a solution for this problem before, but after an extensive search just now, I can only find a million posts relating to this error where users have actually made errors. Please also note that this was a brand new WPF Application and not downloaded from the internet or a network drive.
Is the project ON a network drive? XAML has issues with projects stored on a network drive. In corporate environments your Documents are often remapped to a network path, causing this problem for the default project folder.
Try like c:\projects\yourprojecthere instead?
WPF Project on a network share with clr-namespace

EntityFramework enable-migrations ArgumentException

I am a newby in the beautiful world of Microsoft Azure and made my first hello world website. The next step is to create a database (entityframework) but I get an exception while creating the database from PackageManagerConsole (PMC). I read a few posts on the web that explained that I need to add the startupprojectname to the PS command, but unfortunatelly that doesn't resolve my problem.
I have 2 projects in my solution.
"partyonwebsite" which is the startup project and obviously my website :).
"models" where I will design my models / entities.
In the "models" project I have the classes "User" and "UsersDb". UsersDb is the class that inherits from DbContext.
Now, when I execute the following line in PMC:
enable-migrations -StartUpProjectName "PartyOnWebsite" -ContextTypeName "Models.Users.UsersDb"
I receive the following (not very helpful) error:
System.ArgumentException: The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))
The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))
I've had a look at get-help enable-migrations and played around a bit but not a lot of luck.
Did anybody bump into the same problem? Or can you point me in the right direction to help me solve it?
Thanks a lot in advance!
Bas
Solved. If you run into the same problem, make sure that EntityFramework is setup correctly for your seperate "Models" project.
Open "Manage NuGet packages for solution" in solution explorer (right click solution in solution explorer)
Select "Installed packages"
Select "EntityFramework" and click "Manage"
Check your "Models" project (I checked both my website project and the "models" project)
Run your enable-migrations command again.
I also added a project reference from my Website project to the Models project, I don't know if that matters.
The command that successfully executed after my adjustments in NuGet:
enable-migrations -ProjectName Models -ContextTypeName Models.Users.UsersDb
Hope this answer helps another lost soldier in his path to get his first app running in Azure :).
Cheers,
Bas

Cannot publish because a project failed to build and Could not find file 'obj\x86\Debug\MyApplication.exe' Errors

I am striving to get the source of my issue but no luck. I did check almost all suggestions to fix this problem when publishing project (publishing using right-click, checked DevExpress is not installed).
-Regarding DevExpress the application have some of it's assemblies.
- Cannot publish because a project failed
- Could not find file 'obj\x86\Debug\MyApplication.exe'
I did send publishing diagnostic to the Output and get this :
Task "GenerateApplicationManifest" (TaskId:158)
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(2580,9): error MSB3113: Could not find file 'obj\x86\Debug\MyApplication.exe'.
Done executing task "GenerateApplicationManifest" -- FAILED. (TaskId:158)
Done building target "GenerateApplicationManifest" in project "MyApplication.csproj" -- FAILED.: (TargetId:194)
Can someone list all things I have to check to get this issue fixed ?
I just ran into the problem today. In my particular case, it was caused by this Microsoft Windows Update.
I uninstalled that update and publish began working as it always had. This is only a temporary work around and means you should probably regenerate your keys/certificates.
Right click on you Project
Click Publish
Go to Settings Tab
Click File Publish Options
Check All the options in the tab (As seen in attached image)

Unable to change Manifest for deployed WPF application

Well.. what I'm really needing is to allow the user to install two different versions of the same application. Changing the assembly name just generates a lot of errors that require too much work. I've been reading that changing the assembly identity tells WPF that those are different applications and so the second application (it's a ClickOnce) doesn't replace the previously installed. Sadly this cannot be change inside VS2010.
I've changed the MyApp.exe.manifest here, I Think:
assemblyIdentity name="MyWPFApp_NEWNAME" version="1.0.0.0" language="neutral" processorArchitecture="x86"
And resigned the manifest this way:
mage.exe -update MyWPFApp.exe.manifest -certfile D:\MyDir\MyWPFApp_TemporaryKey.pfx
mage.exe -update MyWPFApp.application -appmanifest MyWPFApp.exe.manifest -certfile D:\MyDir\MyWPFApp_TemporaryKey.pfx
the signing states sucessfull, but when trying to open the application it get an error stating that the Hash is misscalculated...
As this is my first try to modify a deployed application with no doubt I'm doing something wrong...
Have you tried right clicking on your start-up project and going to properties. Then in properties in the "Application" tab look for "Assembly Information" button. Click that button and change the desired values. Rebuild your project and then try to get the user to install this version while an older version is still installed.
Solved... (this always happens to me as soon as I post a question) for client to detect the versions as different applications all I needed was to create a different key file (pfx) for each deployment and change the "Name of application group" in the application properties.

Resources