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

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) !

Related

UnityPlayer_UAP_ARM64_release_il2cpp.pdb not loaded

I've installed several packages in a Unity (2020) app I'm building. Namely: World Locking Tools, MRTK, PUN2. World Locking Tools provides some examples that are built with assemblies defining scripting symbols that any derived files I want to build would need access to. I'd like to create my own version of certain files from one of these examples. To do this and have access to the scripting symbols in one of those examples, I created an assembly reference to reference the assembly for that example code within World Locking Tools package installed in my project space. In so doing, I kept running into the common "...not found, are you missing an assembly reference" issue, which ultimately led me to creating assembly references for many of the assemblies provided by the various packages I needed to use (not just the particular example code I initially wanted to modify). Once my project finally built successfully in unity, I then tried to upload to a Hololens 2 headset in Visual Studio. This provided the error in the title of this post. Coincidentally, the app also appears to fail to start on the headset. Before I tried to alter my codebase with modified versions of files from that World Locking Tools example and with assembly references, the code would successfully build in Unity and successfully deploy to the Hololens 2 headset.
Does the behavior and missing .pdb error I describe mean that I'm missing assembly references for yet other packages even though Unity successfully builds the project?
This is my first foray into using assemblies so be please be gentle :)
For the .pdb message, that one is ignorable since will not have that symbol available. However, the app not starting is definitely likely due to a missing component or loading issue. When ran in debugger, may get a better idea on what is missing or from a debugger log in Unity.

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..

Visual Studio 2010 keeps complaining about Invalid XML although there is none (WP7)

I experience a strange behaviour in Visual Studio 2010 when creating Windows Phone 7 apps. After some time VS starts to complain about Invalid XAML although there is no problem and the app compiles and runs just fine.
It bugges me because I cannot use the visual desingner saying "Exception was thrown on "DataTemplate": Invalid XML" and there is a DataTemplate higlighted in the code. The data template is always ok, VS does not complain about it when copy-pasted to another project.
I found out that problematic are usually the DataTemplates with custom converters or when usin g classes like PhonePerformance.
Sometimes the error is "Exception thrown was due to document error: Invalid XML" and nothing is even highlighted in the XAML file.
I tried reinstalling .NET. Visual Studio etc. and the problem occurs on two separated machines so I do not think it is specific to my configuration. It may be specific to my code.
Anyone experienced similar behaviour?
When using XAML, if you reference a library that needs to be evaluated but can't be at design time you get this kind of error. You can turn off the visual editor and just work in XAML - that will stop the error (and save you time).
You reinstalled .NET and VisualStudio??? You should have just spun up a second instance, opened the solution in both, then attached the debugger from one to the second and opened up the visual editor. It would have told you exactly what in your code was causing the problem. Also DesignerProperties.IsInDesignMode in your converters. Jeez. You wasted so much time :(
As for design time data, that's tricky. Either you have DesignTimeDataWithDesignTimeCreatableTypes that aren't or DesignData that can't create proxies for your real types (for whatever reason, had this issue many times deep in the past).
The only way to figure this out is to debug one instance from another. Its actually not that hard. I do it alot (debugging WF4 ActivityDesigners).
A friend has found a solution and you would not believe where the problem is. This happens if you have a space in the name of your assembly. I found out that I really have a space in assembly name in all the problematic projects, renamed the assemblies and the designer works again.
The solution is also mentioned here http://forums.silverlight.net/t/115011.aspx/1

mxmlc compiles differently under linux and windows?

I have a project which has several components loaded by a single preloader swf.
The preloader swf is strictly AS3 (No flex) and uses Loaders to load two different swfs which both use the flex library (Statically compiled, not rsl).
When I compile all three under linux and run the resulting preloader, one of the swfs fails to load properly, and the exception below (at the bottom of this post) is thrown.
If I compile the same component using the same ant task in windows, the component loads just fine without error. The windows file is also 683 bytes smaller.
This is true using the flex SDK 3.2.0 and 3.3.0 under linux and windows.
Have you seen this type of behavior? Can you offer any suggestions for why it might be happening, or how to determine what is wrong?
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at mx.managers::FocusManager/activate()
at mx.managers::SystemManager/activateForm()
at mx.managers::SystemManager/activate()
at mx.core::Application/initManagers()
at mx.core::Application/initialize()
at OC_Footer/initialize()
at mx.managers::SystemManager/http://www.adobe.com/2006/flex/mx/internal::childAdded()
at mx.managers::SystemManager/initializeTopLevelWindow()
at mx.managers::SystemManager/http://www.adobe.com/2006/flex/mx/internal::docFrameHandler()
at mx.managers::SystemManager/docFrameListener()
So wait, are you using different version of the SDK in each platform? That would certainly account for some differences (at the very least in the size of the swf...)
IIUC you get this error when you're loading the page in the browser, right? It's hard to tell from just the stack trace what's wrong, but I can tell you that I used to get a similar error on Windows and it had to do with keyboard events (e.g. using the tab key to move between elements when popups are visible, and similar stuff). Sorry I can't offer a more accurate diagnosis.
I'm not sure I've solved the real problem (Why the compilation was different under different OS's), but I have found that the newer version of the flex SDK does not exhibit the same issues.
I created a bug for the issue here:
https://bugs.adobe.com/jira/browse/SDK-20147
The short of it is, build 3958 (The one default with flexbuilder at the time that I created the bug -- This may still be true) appears to have a number of minor bugs. Upgrading the flex SDK to build 4852 alleviates the symptoms, and I can build projects successfully in a number of environments.

Strange VB6 build problems (related to nlog)

This I think is related to my use of the nlog C++ API (and my question on the nlog forum is here); the purpose of my asking this question here is to get a wider audience to my problem and perhaps to also get some more general ideas behind the VB6 IDE's failure to build in my particular scenario.
Briefly, the problem that I am having is that I am having trouble building VB6 components which reference unmanaged C++ components which have calls to nlog's C\C++ API (which is defined in NLogC.DLL). The build problems are not occurring during compile time, they are occurring when the binary is being built which suggests to me that it's some kind of linker type problem? Don't know enough about how VB6 binaries are produced to tell. The VB6 binary is produced, but it is corrupted and crashes shortly after it is invoked.
Has anyone had any similar experiences with VB6 (doesn't have to be related to nlog or C++)?
edit: Thanks for all the responses to this rather obscure problem. Still no headway unfortunately; my findings since I posted this:
'Tweaking' the compile options doesn't appear to help in this problem.
Adding a reference to the nlog-enabled C++ component from a 'blank' VB6 project doesn't crash it or cause weird build problems. So it isn't a 'native' VB6 issue, possibly an issue with the interaction between nlog and the various components and 3rd party libraries used by other referenced components?
As for C++ calling conventions: the nlog-enabled C++ component is - as far as I can see - compliant to these conventions and indeed works fine when referenced by VB6 as long as it is not making any nlog API calls. Not sure if the nlogc.DLL itself is VB6 compliant but I would have thought that that is immaterial since the API calls are being made from the C++ component; VB6 shouldn't know or care about what the C++ component is referencing (that's as far as my understanding on this goes...)
edit2: I should also note that the error message obtained during build is: "Errors during load. Please refer to "xxx" for details". When I bring up the log file, all that there is in there is: "Cannot load control xxx". Interestingly, all references to that particular control disappears from that particular project resulting in compile errors if I were to try to build again.
Got around the problem by using NLog's COM interface (NLog.ComInterop.DLL) from my unmanaged C++ code. Not as easy to do as the C\C++ API but at least it doesn't crash my VB6 components.
I would try tweaking some of the Compile options found in the Project, Properties menu, Compile panel to see if they yield any additional hints as to what is going wrong.
For example if you compile the executable to p-code rather than native code does it still crash on startup.
What error message do you get when you run your compiled binary?
I doubt the compiler/linker is the problem: project references in a VB6 project are not linked into the final executable. A project reference in VB6 is actually a reference to a COM type library (which may or may not be embedded in a .dll or other binary file type). Project references primarily serve two purposes:
The IDE extracts type information from the referenced type libraries which it then displays in the Object Browser (and in the Intellisense drop-down)
At compile-time, the compiler extracts the type information stored in the referenced libraries, including the CLSID of each class that you instantiate, and embeds this data into the executable. This allows your executable to create instances of classes contained in the libraries that you referenced.
Note that the compiled binary doesn't link to any code in the referenced libraries, and it doesn't even contain the filenames of the referenced libraries. The final executable only contains the CLSID's and other type information that it needs to instantiate COM objects at run-time.
It is much more likely that the issue is with NLog, or with how you are calling it from your code, rather than something gone awry in the VB6 compile process.
If you think it might be a linker problem, this should crash it the same way:
create a new standard project (of any kind)
add a new module and copy the "declare"-statements into it
compile
If it doesn't crash it is something else.
It would help an exact description of the error or a screenshot of what going on.
One thing to check is wherever NLogC.DLL or the C++ DLL you built have the correct calling convention defined. Basically you can't have the DLL function names mangled or use anything but the STDCALL calling convention. If the C++ DLL has not been created with those two things in mind then it will fail to work with VB6.
MSDN Article on Calling convention.
"Cannot load control xxx" errors can be caused by .oca files which were created from a different version of an .ocx than currently used. If that is the case, deleting the .oca files helps.

Resources