System.Reflection.MissingRuntimeArtifactException - in release mode - linq

I'm trying to compile UWP app. It runs fine in Debug mode, but when trying to run it in release mode I get this error:
Exception thrown: 'System.Reflection.MissingRuntimeArtifactException' in System.Private.Reflection.Core.dll
Additional information: MakeGenericMethod_NoMetadata, System.Linq.Enumerable.Distinct<System.Int32>(System.Collections.Generic.IEnumerable<System.Int32>).
When breaking in the exception in VS2015 also get this message (still release mode):
ExecutionEnvironment.cs not found
I found a similar issue/solution in SO, but that didn't work in my case: https://stackoverflow.com/a/31548178/4140832
I'm using the UWP SDK 1.1.
UPDATE: I also found this: http://dotnet.github.io/native/troubleshooter/method.html#
... but I'm unsure if this is the answer and unsure how to use the tool based on the information provided above.
UPDATE 2: .NET Native General Troubleshooting: https://msdn.microsoft.com/en-us/library/dn600643(v=vs.110).aspx

I found a solution. It turned out to be related to the particular combination of AutoMapper and .NET Native. Changing Runtime Directives was a detour in this particular case.
In my code I had a AutoMapper configuration that looks something like this:
Mapper.CreateMap<SomethingGood, ISomething>().As<SomethingBetter>();
This works when the app was not compiled to the .NET Native tool chain (i.e. when running in debug mode). However, when compiling for release this AutoMapper code breaks.
Also, in the class SomethingBetter I had more properties defined than what was defined in ISomething and the SomethingGood class. This was a mistake, but it went unnoticed in debug mode. When compiling to .NET Native the App would throw a 'System.Reflection.MissingRuntimeArtifactException'.
To track down this bugs I used the .NET Native debug engine. Without using this it was close to impossible to figure out that was the root cause for the exception.
This blog post explains using the .NET Native debugger very nicely: http://blogs.msdn.com/b/visualstudioalm/archive/2015/07/29/debugging-net-native-windows-universal-apps.aspx
Also, putting this try/catch at the end of all the AutoMapper.Mapper.CreateMap's was very helpful to track down the properties causing the issue:
try
{
AutoMapper.Mapper.AssertConfigurationIsValid();
}
catch (Exception ex)
{
throw ex;
}

Related

Xamarin.MacOS SignalR: Cannot resolve the reference System.Readonly Memory System.Byte Microsoft.Aspnetcore.SignalR.Protocol.Handshakeprotocol

I am working with both AutoFac and SignalR, and everything works great in debug mode for Xamarin.Forms.MacOS.
Since I use autofac, I need to set Link Framework SDKs only, if not, I get a runtime exception in releasemode.
Now my current issue is that i have a compilation issue when setting it to Link Framework SDKs only. The followingn error i get looks like this:
Cannot resolve the reference system.readonly memory <system.byte> microsoft.aspnetcore.signalR.protocol.handshakeprotocol
If i set my Linker to Link all, then I can successfully launch the app, but as stated above, I get a Runtime exception because of an issue with Autofac.
Any idea on how i can solve this?

Resource-related error condition in Windows Forms C++ application

I am working on a legacy Windows Forms application using VS 2008 under C++ and face a weird problem. The form uses an ImageList object, to which two bitmap images have been added. At run-time, I get the following error in Debug mode (in the Release mode, the application just doens't launch):
An unhandled exception of type 'System.Resources.MissingManifestResourceException' occurred in mscorlib.dll
Additional information: Could not find any resources appropriate for the specified culture or the neutral culture.
Make sure "MyApp.Form1.resources" was correctly embedded or linked into assembly "MyApp" at compile time,
or that all the satellite assemblies required are loadable and fully signed.
The crash occurs at the first line of this block:
this->imageList1->ImageStream = (__try_cast<System::Windows::Forms::ImageListStreamer* >(resources->GetObject(S"imageList1.ImageStream")));
this->imageList1->TransparentColor = System::Drawing::Color::Transparent;
this->imageList1->Images->SetKeyName(0, S"Nok32.png");
this->imageList1->Images->SetKeyName(1, S"Ok32.png");
This is pretty puzzling, because I copied the application from an existing one which works fine. I just changed the namespaces. And if I remove the two images from the list, the application works.
I found several posts on forums about this or similar problems, but none could really help me. I don't think that Visual Studio can be blamed. I tried with frameworks 2.0 and 3.0, to no avail. Fully comparing the sources of both applications, I can't see a significant difference.
Any hint ?
Solved: there was an old namespace left in the project file (.vcproj) !

ros::init(...) throws an error - Windows roscpp

I'm trying to use ros in cpp with Visual Studio 2012. I wrote the publisher and subscriber tutorial (http://wiki.ros.org/ROS/Tutorials/WritingPublisherSubscriber%28c%2B%2B%29) and first, I configure the project as says in the guide (http://wiki.ros.org/win_ros/hydro/Msvc%20SDK%20Projects).
Then i compiled an linked the publisher, but when I tried to run it, ros::init(argc,argv,"talker") throws an exception... The console says that I ROS_MASTER_URI is not defined but I've got it defined
There are 2 images here:
https://www.dropbox.com/s/o12m0l38gaxiugi/error1.png -
https://www.dropbox.com/s/ocdmf0wj6rj0962/error.png
Can anyone helps me?
Thanks in advance
So, I had the same issue, although I didn't set the ROS_MASTER_URI globally.
I managed to get around this specific issue by adding
ROS_MASTER_URI=http://localhost:11311
to the debugging environment variables (Project->Properties->Configuration Properties->Debugging->Environment).
However, after implementing the above I got an uncaught exception (Unhandled exception at 0x768bc41f in ros_demo.exe: Microsoft C++ exception: std::bad_alloc at memory location 0x0028f0e4..).
That went away when I built, compiled and ran the project in release mode (which matched my ROS SDK build).
I got the idea for the release/debug build from here:
xstring isn't an OSG specific object, so the error is elsewhere in the
3rd party dependency chain. As I know nothing about your OS and
software setup I can't speculate what this might be.
In general though this type of error could well be a linking issue -
for instance Visual Studio is hopeless at handling different libs
being built debug and release and will crash randomly.
That was fun to discover..

Why has Visual Studio's Windows Forms Designer stopped working?

I'm in the process of cleaning up an old bit of C++-CLI software by decoupling business logic from the GUI. Despite the fact that I've left the windows forms designer code well alone, it now won't display my form and instead, throws an exception:
Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))
The call stack looks like this:
at EnvDTE.CodeFunction.GetStartPoint(vsCMPart Part)
at Microsoft.VisualC.CppCodeParser.OnMethodPopulateStatements(Object sender, EventArgs e)
at System.CodeDom.CodeMemberMethod.get_Statements()
at System.ComponentModel.Design.Serialization.TypeCodeDomSerializer.Deserialize(IDesignerSerializationManager manager, CodeTypeDeclaration declaration)
at System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager manager)
at Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager serializationManager)
at System.ComponentModel.Design.Serialization.BasicDesignerLoader.BeginLoad(IDesignerLoaderHost host)
...none of which is my code. What might I have disturbed?
Based on the call stack it looks like the WinForms designer is choking trying to read the code inside the InitializeComponents method in the generated file. The actual faulting party is the C++ code model implementation.
What's most likely happening here is a particular statement in the method is causing the code model to error here. I would start by commenting out the entire method, verifying that fixes the problem and then slowly uncommenting sections until I tracked down the offending line
Check if there is none of your own code in InitializeComponent() function.I replaced it and it works normally now)
i googled the error and there were a few threads citing various different applications that all produce this error:
http://forums.iis.net/t/1148764.aspx/1
and
http://social.msdn.microsoft.com/Forums/en-US/vsto/thread/11e91d76-f5f3-45c3-b3f6-30c1e4121b9f/
being just two
the chief cause of this error seems to be a user or process attempting to access, run or write to something it does not have access to.
Have you tried running the application as an administrator?
if that doesn't work make sure both the project folder and the application folder are on the same partition as that can affect permissions.
you have not upgraded your OS since that application was installed by any chance? If so your GUID may not match the stored GUID on the Application and that could be causing the error uninstalling/re-installing will fix this.
hope that helps

Using .Net Framework Source debugging

I'm getting a null-object exception deep within XsltCompiledTransform, and I'd like to use the .Net Framework Source debugging feature to see what isn't being initialized, but even after following the directions for enabling it, I can't figure out how to step into the .Transform() method and start spelunking.
The tutorials I've found online say you can load the symbols for the framework library by using the Call Stack window while debugging, but this isn't useful when the callstack has yet to contain the library you want to debug. I've also tried loading symbols from the Modules window, but Step-Into still doesn't work.
Is the System.Xml.Xslt namespace source even available to step into when debugging?
If you have trouble fetching the sources on the fly, you might want to try out .NET Mass Downloader
As it looks, the sources for XsltCompiledTransform are included.

Resources