running Winform Application - winforms

detailed message box texti made a winform application on my pc and it runs fine. but when I tried to run it on another PC by copying the exe file and other dll files there , the application failed to run and all of a sudden it shows a dialog box to close the aplication.
please refer to screenshot of error.
enter image description here

Like bassfader said: One possible explanation is that your application is handling files during startup. In that case: integrate more extensive exception handling for those parts. Potentially with logging, to locate the problem
In my experience this however is more often a case of missing some kind of dependency.
Double check .NET runtimes. Lookup the target .net version in Visual Studio and run the installer on the target machine.
Investigate if your app uses any assemblies that are not part of the .NET framework. Sometimes these are not copied to the bin directory if they are in the GAC (ensure the flag "Copy Local" is set to "Always" in Visual Studio)
Ensure you have copied the whole bin folder
Check compiler output to see if you've got Platform mismatches. IIRC this can sometimes work fine on a dev machine but cause problems when Visual Studio is missing or you get to a different OS.

Related

Publish WPF + EF Core App with Windows Installer Project

I have tried to create an .exe file to my WPF App and SQL Server related databse with EF Core using Windows Setup Installer Project.
I included all the dll's files from /bin/Release and built it for any CPU.
The Setup Project has been created successfully and it worked on my PC as I expected.
Otherwise when I try to install the Setup File on another PC, I can't even open it up and see what's wrong.
I guess the problem comes from the database but I can't find anything helpful on the internet.
So you get the application installed, run it and nothing happens, right? Here is what you do:
Run it. Watch nothing happen
Hit the Windows key and type "Event"
When "Event Viewer" appears in the list of applications, run it
In Event Viewer, go to Windows Logs >> Application
Near the top there will probably be an error entry. It will probably be related to your application. And if you were missing a key file needed to run your application, like a DLL, the name of the file will probably be in there in the details section
Go back to your installer and add that missing file. Or if that file is part of some support package (like, say, MS Redistributable for Visual C++) then add the installer for that too.

How does a WinForms .Net sub-application in a solution embed its app.config into itself?

I am using a variation of Jeff Atwood’s Unhandled Exception handler it steps in when there is an Unhandled Exception in the application. It then logs the error, generates a screen shot and notifies the user.
When compiled in a solution the project generates an EXE that is called when needed. In updating the program I am using Visual Studio 13 to edit the existing settings items in the project properties. In the code I use commands such as this from ConfigurationManager.
string appProduct = unhandledExceptions.Properties.Settings.Default.AppProduct;
I was happy to see that it worked and reflected the changes I made in the IDE. However I couldn’t find the settings in the solutions generated confg file (MyApplication.exe.config). I assumed it was reaching back to the other project folder for the UnhandledExceptions.exe.config.
I created an installer and installed it to a virtual machine. My settings carried over, but again I could not see a config file.
It turns out the values are embedded in the executable UnhandledException.exe.
The project does not have any resources listed. Searching the web and StackOverflow looking a questions that want to do this, and there are a lot of them, it seems this was generally considered not possible and not desirable. Questions usually end in “You don’t want to do that, it’s called config for a reason”.
I may want to turn this off, so it is editable externally. The properties of app.config in both projects are identical.
What setting is making this possible after all? Is it a new capability with Visual Studio 2013?
There is no Visual Studio setting required. If you don’t want the user to have access to the configuration file, don’t include it in the distribution. One can always be added if the settings names are known.
In the description below application generically represents the name of the application being used.
I’ve found through observation some interesting things about the way ConfigurationManager works.
For User settings it will look in the following places in order of priority:
user.config for the application in the user’s AppData area
application.exe.config in the program folder
application.exe itself
Each setting is searched for individually. If your application requests a setting that is not found in either user.config or the application.exe.config it will get it from the executable.
For Application settings it looks in the following places in order of priority:
application.exe.config in the program folder
application.exe itself.
There is no equivalent to user.config for application settings.
Opening the application.exe in the Visual Studio IDE does not reveal a resource for the configuration information.
application.exe.config is handy because it can be modified externally and used as a default value for new installations. Once a setting is overridden in the user.config the value in application.exe.config is ignored.
The same is not true for the AppSettings section, the older configuration method from .Net 1.0. If I delete the configuration file it does not have them in the executable.
These observations were made with Visual Studio 2013 Update 4 and tested in Windows 7 Professional 64-bit. I suspect they are true in all versions.

Can't run Xilium. CefGlue built on Visual Studio 2012

'Hi all, I downloaded Xilium.CefGlue and built the source on Visual Studio (xilium-xilium.cefglue-b22787699e57), I also downloaded cef_binary_3.1453.1236_windows_xilium and copied the libcef.dll to the Xilium Winforms demo as the apps requires it to run but when I run it I get the following error:
An attempt was made to load a program with an incorrect format.
Exception from HRESULT: 0x8007000B
I've targeted x86, can I get some help?
Thanks
Ok, here's the steps I used to get the samples working in VS 2012:
Get the code from Xilium.CefGlue on github. (The one I used was c3d674a3a8)
Open the Xilium.CefGlue solution in VS2012
Remove or don't build the CefGlue.Demo.GtkSharp project (it didn't interest me & I didn't have the needed libraries)
In the Configuration Manager, select Active Solution Platform to be x86
Ensure that the target framework settings cooperate between projects. (e.g. CefGlue.Demo & CefGlue.Demo.WinForms by default are v2.0, but they depend on CefGlue which is v4.5) (For simplicity I set them all to v4.0 Client profile and it worked.)
Build solution — should succeed
Copy Xilium files from the unzipped cef_binary_3.1453.1236_windows_xilium to the output folder (bin\x86\Debug or bin\x86\Release). Minimum requirement seems to be:
libcef.dll and icudt.dll from .\Debug or .\Release
cef.pak and the locales\ folder from .out\Debug or .\Resources
Set CefGlue.Client as the StartUp Project
Run it

IIS related System.ExecutionEngineException

After too many hours of research I have come up with nothing to solve this problem.
I am running a WPF program in an .xbap page file being hosted on internet explorer. Running the project in Visual Studio 2010 works just fine and generates no errors.
I want to be able to host the webpage on IIS 7.0 and to browse to it with a windows forms application. To test this I created a new website on port 80 in IIS manager. I then published the project to the local website folder and added the autogenerated project certificate file (projectName_TemporaryKey.pfx) to my Trusted Publishers and Trusted Root Certification Authorities.
My problem is this: whenever I try to browse to the file with internet explorer or with my windows forms program, the wpf program stops working. When pulling up the just-in-time debugger, I am informed that there is a System.ExecutionEngineException but am given no source code, no stack trace, and no data outside of an empty Dictionary enumerable. My guess is that this might have something to do with the database call made in the program to another machine, but I can't prove that.
I've tried several things to solve this including repairing my .NET 4.0 framework and altering permissions but nothing seems to be affect the error.
Does anyone know of a way to get more information on this error, or perhaps a step I may have missed when publishing this project?
Thanks very much.
Some things to check:
Windows event log often includes additional exception information (although usually in an awful format)
Output some trace information from your application so you can follow what's happening
Try attaching a debugger to the WPFHost and then stepping through the code

Silverlight project build fails in VS2010 when project is on a mapped network drive

I am just learning Blend/Silverlight/VS2010/.net/etc. I have a simple project that resides on a network drive. When I tell VS2010 to rebuild the project, I get the following error message:
------ Rebuild All started: Project: MySilverlightApplication, Configuration: Debug Any CPU ------
MySilverlightApplication -> H:\PRJ\VisualStudio\ExpressionBlend\Unleashed\MySilverLightApplication\MySilverlightApplication\Bin\Debug\MySilverlightApplication.dll
C:\Program Files\MSBuild\Microsoft\Silverlight\v4.0\Microsoft.Silverlight.Common.targets(214,9):
error : Could not load the assembly
file:///H:\PRJ\VisualStudio\ExpressionBlend\Unleashed\MySilverLightApplication\MySilverlightApplication\obj\Debug\MySilverlightApplication.dll.
This assembly may have been downloaded from the Web. If an assembly has been downloaded from the Web,
it is flagged by Windows as being a Web file, even if it resides on the local computer.
This may prevent it from being used in your project. You can change this designation by changing the file properties.
Only unblock assemblies that you trust. See http://go.microsoft.com/fwlink/?LinkId=179545 for more information.
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
The project was not downloaded from the Web (I created it using Blend.) After doing some searching, I guessed the problem may be due to .net security settings. I issued the following command:
C:\Program Files\Microsoft Visual Studio 10.0\VC>caspol -m -ag 1.3 -url "file://\\p4dc\h$\*" FullTrust
in the hope that would solve the problem. p4dc is the name of the server machine, h$ is the administrative share for the h: drive on the server which in turn is mapped to the drive letter "H" on the local machine (\\p4dc\h$ is mapped to H in the local machine).
That did not solve the problem. I don't know if my caspol command is correct (I wasn't planning on learning caspol on the fly), it just seemed like a reasonable thing to try. The problem goes away when I make a copy of the entire project on the local C drive but, that "solution" is rather undesirable.
At this point, I don't really know what else to try to solve the problem without moving the project to a local drive.
Any help leading to a solution is much appreciated.
John.
The error message displayed by VS2010 would lead anyone to believe the issue is with trust and security and it is BUT, no amount of allowing full trust on the network drive will solve the problem.
What lead to the solution was first to port the project to VS2008 to find out if it would encounter the same problem. VS2008 was perfectly happy to run the project without complaint.
Then I converted the VS2008 project (which was working) to VS2010. VS2010 refused to build the project but this time the error message was different, referring to "remote assemblies" and to a link on MSDN, which led to the solution.
The real problem is that VS2010 considers an assembly on a network drive a "remote assembly" (the same as if the assembly were being loaded from a web site.) Caspol was not able to solve that problem (it seems it should have but, it may be my fault, I am not well versed in using Caspol).
To end this long story, the link provided in the error message is:
http://msdn.microsoft.com/en-us/library/dd409252(VS.100).aspx
after following the instructions in that link to edit "machine.config", I changed <runtime/> to:
<runtime>
<loadFromRemoteSources enabled="true"/>
</runtime>
the project built successfully and ran without a hitch.
Thank you to Alison and CodeNaked for their efforts to help,
John.
PS: it would have been rather nice if VS2010 had displayed the "better" error message initially. Instead, I had to port the VS2010 non working project to VS2008 where it worked and that one to VS2010 where I got the better error message that led to the solution.
Not sure if this will help but it's worth a shot: How Do I Allow my Visual Studio .NET Projects to Run from a Network Location?

Resources