Embedding a file in an assembly

Why? I have some unit tests that need to run off of some pre-defined static XML data and while the tests run fine so long as the file and assembly are in the same location as soon as the assembly is moved elsewhere they start to fail, “file not found” exceptions.
So if the file is embedded in the assembly I don’t need to worry about where it is located anymore.

The assumption, in the following, is that the file is XML that has been serialised from an existing List and is being reloaded back into the same, and that the file is in the current assembly. “_states” is a global variable.

So here are the basic steps for this:

In your Solution Explorer view right-click on the file, in this case “state.xml”, and view it’s Properties, make sure that the “Build Action” is set to “Embedded Resource”, optionally set the “Copy to Output Directory” to “Do not copy”.

Once this has done then the file can be loaded and copied into the required object using:

GetFileFromAssembly

An important thing to remember is that the “Namespace” prefix to the file is the “Default namespace” as entered in the Application properties tab and not the namespace used in the referencing file.

You can reference the file, if it’s in a sub-folder by adding the folder just after the namespace, e.g.

GetFileFromAssemblyNamespace

 

 

Advertisements

VMWare memory configuration tweaks

Make sure the VM machine you’re going to be changing is shutdown/powered off first.
Then edit the .vmx file and add the following:


mainMem.useNamedFile = "FALSE"
MemTrimRate = "0"
sched.mem.pshare.enable = "FALSE"
prefvmx.useRecommendedLockedMemSize = "TRUE"
prefvmx.minVmMemPct = "100"

mainMem.useNamedFile – stop the VM from creating a memory mapped file (on disk).
MemTrimRate – Disable memory trimming.
sched.mem.pshare.enable – Disables memory sharing across running VM’s.
prefvmx.useRecommendedLockedMemSize – No idea, other than this WMWare KB article.
prefvmx.minVmMemPct – Preallocate all RAM available to the VM at startup, reducing this value allows some swapping to occur.

Update: 13-Jan-2016

It seems that this data can be configured on a global, for the current PC, basis. If the changes are applied to the c:\ProgramData\VMWare\VMWare Workstation\config.ini file.

And some additional settings can be added as well to further boost performance when the VM is in use.

priority.grabbed = "high"
priority.ungrabbed = "normal"


The grabbed setting can only be "high", or "normal".
The ungrabbed setting can have a value of "normal",
"low", or "idle".

How to stop Google using your SSID for location services

Just found out that you can stop this.

By default, Google, and possibly others, use your SSID to help improve their location services. You can opt out by changing your SSID, shouldn’t it be if you want to opt in? Anyway if you add “_nomap” then they won’t record your data, alternatively maybe hiding the SSID does the same?
More details here: https://support.google.com/nexus/answer/1725632?hl=en&rd=1

Wrong version of C:\Windows\System32\ATL100.dll

Having problems with this DLL on Windows 7?

In my case this stopped notepad.exe from saving files smoothly, okay how many people use notepad still? The files did save but you had to click through a couple of Window’s dialogs saying that the file was running on the wrong version of Windows. Quite why the 64 bit of notepad was running this is beyond the level of investigation I put into this.

I tried to uninstall it using regsv32 but that also complained it was the wrong version. Right clicking on the file and examining the properties was of no help at all, so maybe it is corrupt? Looking at the ATL110.dll we see that that it has been signed by Microsoft, my version of ATL100.dll didn’t even offer up the tab! Should have taken a screen grab before I replaced it.

atl110 properties
Digital signatures of the atl110.dll

Trying to find similar issues, either via Google or Bing, offered up plenty of sites who would provide a copy – but without having any checksum to work with no way was I downloading them! Also no one seemed to provide any solution, maybe I can’t construct the correct query or I should have gone further into the results.

Next was to try and rollback the file, not an option as by the time I’d found the issue I’d helpfully cleared out, read reset, my system restore and windows backups so they were no use. Running the System File Checker (sfc.exe) showed that there were no problems with the Windows installation.

Okay so back to basics and try and figure it out, with vague recollection of my VC++ days (very vague and no fun) we find the DLL is part of the Active Template Library (the ATL in the file name) part of the C++ 2010 Redistributable package (the 100 in the file name).

To resolve the issue I downloaded the 64 and 32 bit 2010 packages using this link: https://support.microsoft.com/en-us/kb/2977003

First off I ran each installer in repair mode, no luck the error still persisted. The atl100.dll still wasn’t right. So I took the sledgehammer to it and deleted it. Then I ran each installer twice, first removing the package and then to re-install. I didn’t reboot in between removing and installing but it is probably advisable. Certainly once you have re-installed then a reboot would be good practice.

Sorted!