RickStrahl / wwDotnetBridge

.NET Interop for Visual FoxPro made easy
http://west-wind.com/wwDotnetBridge.aspx
73 stars 35 forks source link

Improve diagnostics when CLR load fails #17

Closed breyed closed 6 years ago

breyed commented 6 years ago

I ran into a frustrating problem with CLR load failures on certain computers when running an application that uses wwDotNetBridge was deployed. In the process of debugging, I improved ClrHost to report error information for any failure (vs. only for selected API calls). Once I learned what the error was, I thought perhaps the problem was related to using deprecated CLR hosting APIs, so I added an updated CLR loader.

I also thought for a moment that a .NET DLL I had created using a Microsoft.NET.Sdk-style project was loading whereas wwDotNetBridge.dll was not, so I updated the project format for wwDotNetBridge accordingly. (It turned out that PowerShell, through which I was testing loading, was keeping assemblies loaded, so load attempts that would have failed silently succeeded.)

None of these changes were actually necessary (although the error reporting was quite helpful). It turned out to be just the need for a lousy loadFromRemoteSources line in a .config file, which I considered early on, but had initially ruled out due to misleading documentation.

The good news is the work nonetheless makes for a useful update and future-proofing to the wwDotNetBridge bootstrapping.

breyed commented 6 years ago

I based the branch of this PR on my events branch, which will make merging easy once events is merged. However, I see it causes lots of commits to show. Only the Improve diagnostics when CLR load fails commit is for this particular PR.

RickStrahl commented 6 years ago

Can you do me a favor and break these fixes out into separate more bite sized branches? This merge is getting too big to manage. At least the C++ changes and the core changes.

I will merge things in when I have a little more time to look closer at the code which will likely be later next week.

breyed commented 6 years ago

I cherry-picked the C++ and C# changes and pushed them as breyed/clrhost4-isolated and breyed/netsdk-project. Each of the new branches is based on RickStrahl/master. Hopefully that makes them easy to see in isolation. Merging should still be easy, since I don't think there are any conflicts with the events branch.

RickStrahl commented 6 years ago

I wasn't able to merge this. I tried to cherry pick the changes from the CLR4 commits, but it pulled in other changes that were out of sync with the previous merge.

I just manually merged the two files in and that's working fine.

There are a other things here, but I just don't have the time to figure out exactly what these tweaks are in this bunch of changes. Most of these look like little convenience tweaks. So if you care about these maybe try to merge master back into your final code and see where you land. Most of the important changer are merged in now so we should be close.