Customizing the default "The application failed to initialize properly (0x00000135)" message - vb.net

When the .net framework cannot be found, the following message is displayed:
"The application failed to initialize properly (0x00000135)"
Is there a way to make it a tiny bit more specific (instead of writing a wrapper in another language), eg. by telling the user about the .Net fx?

I believe that the "failed to load" error message is thrown by Windows loader (via Explorer.exe). So, I think there's no way to customize/control the error dialog box and its contents. I can think of few other methods:
- Add .NET version detection in installer package so that installer can inform user to download and install .NET framework if it's not present already.
- Write a stub application in unmanaged code which launches the .NET binary (using APIs like CreateProcess). In this stub, you can check for .NET framework and then display more descriptive error code.
Here's an example that shows how to detect .NET framework and its version:
http://www.codeproject.com/kb/dotnet/DetectDotNet.aspx

Related

VB.NET application compiled to target 4.6.1 framework does't run successfully on Computer with only 4.8 .Net framewor

I intend to build simple Winform application just to allow user to automate their file creation and store the last filled form in a file to keep it for next run.
thus, I'm not interested in creating installer for this simple Winform application. I expected to only compile it to .exe and let it run on other computers.
I develop the application using VS2019 community with target .net 4.6.1
It won't run on computer with Windows 10 with only .net framework 4.8
We are not able to install framework 4.6.1 since it says an earlier version of .net framework is already installed.
Should I recompile my application with target .net framework 4.8?
Can't I compile my application to run on any computer which at least has 4.6.1 or newer? without installer.
(I don't really understand the .net framework backward compatibility truly mean)
my application uses:
library of user32.dll for SetForegroundWindow function
to create .ini file
Finally it works. Even compiled to target .NET 4.6.1 still work on .NET 4.8 computer actually.
The issue is because my application is targeting to another application using interope COM interface, while the license is not sufficient for the user to allow COM interface.
we notice it when we finally create a pure simple windows form, then step-by-step compiling while adding each feature.
Sorry Every Body for this silly case. And my special apologize to evry1falls for spending your time.
I'm thinking to change this Question or delete it. because it is not the issue at all
The Actual Issue is:
I created Windows Form Application starting from a blank Project. And I don't know that the .NET Unhandled Exception is not activated by default.
When created from Windows Form Project Template, the Unhandled Exception message shown.
I created another Question about it: Here

Referencing a COM object via dll in .Net Core 2.0

I am trying to upgrade an old asmx webservice to Web API. Idealy I would like to use .Net Core as that is what we have been developing in. The issue is that the API must communicate with a legacy system using a COM object.
I have copied over the dll (already not ideal, I know) and, the .Net Core API project is able to add it as a reference and the code all compiles. However, on running the code I get the following error when instantiating an object from the dll:
Retrieving the COM class factory for component with CLSID
{CCA0B90B-DFDE-4DD3-9C7B-9769A3F12201} failed due to the following error:
80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).
I've tried to do exactly the same thing using the full .Net framework and everything works as expected so I imagine it is an issue with Core - maybe the portability requirements.
It will not be possible to rewrite the integration to the legacy system at this point and I was just wondering if there was any way around this without using the full .Net framework.
Update
I don't know if this will help but I can created a .Net Framework console app which runs the code just fine. when I reference the project from my .Net Core API and call the exact same code the error above still occurs.

Custom action calling into .NET 4 assembly

I have a .NET library (dll) of helper methods specific to installing my product, that targets .NET 4.
However, the "main" WIX project is targeting .NET 3.5 (as specified in the documentation) (meaning it runs on the 2.0 runtime). It has custom actions that call into the above 4.0 dll.
When running the generated MSI, i get "BadImageFormat" exceptions, when the WIX runtime (running on 2.0 runtime) tries to load my 4.0 dll.
If I had direct access to a .NET 3.5 .exe, I could convince it to load a 4.0 dll by using the trick in its app.config.
However, the WIX runtime is loaded (by msiexec), as far as I can tell from the stack trace, through Interop.
Does anybody have a suggestion on how I could get this to run?
PS. I also tried making the "main" Wix project target 4.0 directly instead of 3.5, but then my setup dialogs will just fail to show.
I don't know how you have this setup in wixsharp, but in Visual Studio WiX has a project template for C#/DTF custom actions. It automatically includes a CustomAction.config that you can use to put SupportedRuntime elements in to achieve what you are trying to do.
Take a look at WIX and Custom Actions
The BadImageFormat exception means that you are attempting a cross architecture call somewhere in your calling sequence, 32-bit to 64-bit or vice versa. That might be a consequence of getting the incorrect framework, but not necessarily!

Why won't my vb.net project recognize its framework?

So I've been working on the same windows form application for a while now. Recently I added a form that uses crystal reports and a crystal reports viewer. Since the addition any attempt at deployment has been unsuccessful.
When I installed crystal reports, I needed to change the framework of my project from 4.0 client to 4.0. On building my solution I received the following error message:
WARNING: The version of the .NET Framework launch condition '.NET Framework 4' does not match the selected .NET Framework bootstrapper package. Update the .NET Framework launch condition to match the version of the .NET Framework selected in the Prerequisites Dialog Box.
Following the message I went to the launch conditions page for my solutions and changed the framework version, but after running another build, the error persists along with a new error:
An error occurred while validating. HRESULT = '8000000A'
I'm using VS2010 and I found through other posts that this was known error and was seemingly irreparable. Does anyone have any suggestions?
Right click on your setup project and choose View->Launch Conditions. Under Launch Conditions click on .Net Framework. Under the properties section, the Version can be clicked on to change it to ".Net Framework 4" from ".Net Framework 4 Client Profile".

How can I make a .Net 4.0 Exe ask the user to download .Net 4.0 framework / redistributable before running this exe?

I thought that latest Matlab does this automatically. I have tested the following exe on a clean Win XP VM:
namespace DotNetTest
{
using System.Windows.Forms;
class Program
{
static void Main(string[] args)
{
MessageBox.Show("Howdy!");
}
}
}
When I run it on a computer which has all these installed, it does show the message box and a window. When I run it on a clean VM, I get this error:
Title: DotNetTest.exe - Application Error
Icon: Error
Buttons: {OK}
Message Body: The application failed to initialize properly (0xc0000135). Click on OK to terminate the application.
I would expect better from MSFT geniuses. Why cannot every .Net exe contain a tiny bit of overhead and have the very first bytes of it do the work of detecting if .Net is installed and presenting a better message.
Is there some sort of setting that I can flip to fix this? All of the settings were default ones provided by VS2010 when I created a new project.
Thank you.
This is what you use an installer for. In .net this is simple, you just "publish" your project and you get an installer that makes shure that .net is installed and such. The application itself should never have to worry about that.
As Alexandr says, you should really use the installer for this. If that's not possible, you'd have to write an unmanaged exe to run first and then either start the .net exe or tell the user to download the framework depending on if it's already installed.