C# Code Loading Plugins Fails Inside Virtual Machine - visual-studio-2010

I am using Win7 Ultimate in a VMWare Player virtual machine, running on a Linux Mint host. Under Win7 I am using Visual Studio Express 2012 to develop an application. On startup this application loads plugins dynamically - the mechanism is fairly classic:
var plugins = new List<IPlugin>();
var domainInfo = new AppDomainSetup
{
ApplicationBase = AppDomain.CurrentDomain.BaseDirectory,
PrivateBinPath = PluginPath
};
var domain = AppDomain.CreateDomain("PluginLoader", null, domainInfo);
var pluginFiles = Directory.GetFiles(PluginPath, "my.plugin.*.dll");
TypesInAssemblyFile finder = (TypesInAssemblyFile)domain.CreateInstanceFromAndUnwrap(
typeof(TypesInAssemblyFile).Assembly.Location,
typeof(TypesInAssemblyFile).FullName
);
var pluginFiles = Directory.GetFiles(PluginPath, "myapp.plugin.*.dll");
This works fine if the solution, project files and sources are located on the virtual machine's C: drive, or on a NAS shared folder. If, however, I move same code to another hard disk located in the same physical machine and shared with the VM using VMWare Player's folder sharing mechanism then I get a System.IO.FileLoadException at the domain.CreateInstanceFromAndUnwrap:
An unhandled exception of type 'System.IO.FileLoadException' occurred in
myapp.modules.dll
Additional information: Could not load file or assembly 'file:///G:\myapp\my\path
\bin\Debug\myapp.modules.dll' or one of its dependencies. Operation is not
supported. (Exception from HRESULT: 0x80131515)
This physical disk is mounted using VMWare Player's shared folder mechanism, the path \\vmware-host\Shared Folders\Data is mapped to a G: drive and everything looks fine.
Does anyone have any clue why? I've loaded the DLL in Dependency Walker and don't see anything obviously wrong and the same code works fine on the virtual machine's C:.

Related

Empty list on "Where do you want to install Windows" in VirtualBox

I'm creating a virtual windows 7 enterprise 64bit on my new Macbook Pro using VirtualBox.
Following the wizard, I selected the correct operating system, allocated 512 RAM, 50GB VDI storage (dynamically allocated), and on startup I injected my ISO installer file as the CD to boot from.
Then I started my new virtual machine.
But I can't get any further then the first screen "Where do you want to install Windows". It displays an empty list and I don't get options to partition anything or make a new disk.
The VDI file is however present in the appropriate VirtualBox VMs folder on my Mac. I tried giving every file and directory in that folder all rights, but that doesn't solve the problem.
Also, when I look to my VM settings, in the Storage tab there seems to be a Controller: SATA item present, containing the Windows 7 64bit.vdi
I completely erased VirtualBox (including all settings files) using an App remover tool, reinstalled it, but still I can't get any further, it keeps displaying an empty list.
What am I missing here?

Virtual Box Shared folders on Mac backup to external harddrive

So I found out how to share folders using Virtual Box and running Windows 8.
I was wondering, if I save files or projects from Windows 8 to the shared folder on my Mac, will TimeMachine backup those files onto my external harddrive? The hard drive is of course formatted for Mac because of that whole debockel, but that is besides the point. Even though the files were made in Windows.
Also...My assumption is that I would not be able to access the files on my external formatted hard drive from Virtual Box running Windows 8. Is this true?
To my knowledge, you cannot access the files on a journaled formatted hard drive from Windows without extra software. If I understand you correctly, you are trying to backup files created in the Windows VM within your Time Machine backup hard drive?
I'm sure you have solved this by now, but you should consider backing up the VM itself. If the files on the Windows Machine are important you can leave them in a shared folder and have time machine back up that folder.

Running and debugging program from Visual Studio in virtual machine like VirtualPC or VirtualBox

I have program that I want to test on clean Windows installation. For now I have image in VirtualBox and I start program from shared folder, but this is not comfortable and I can't debug.
For debugging I found that I can use Remote Debugging Monitor, but still I want to automate whole process, especially uploading application on virtual machine.
I thought that VirtualPC would be better then VirtualBox, because this application was created by Microsoft. Unfortunately I can't find any info how to connect them.
EDIT:
After research: only possibility is to treat virtual machine as remote computer. There is no easier way. Project need to be published to VM using shared folders. After configuring in Visual Studion new release type for remote debugging all triggers automaticly and working.
I would:
1.Place the program in a pre-defined shared directory, such that it is immediately visible to the virtual machine after redeployment.
2.Remote debugger invokation can be automated - all the parameters, such as users allowed to debug can be passed on the command line.
VirtualBox is quite OK for this task, as it allows you to replace only the disk image with clean one, while leaving the setup, including shared directories intact. I am sure VirtualPC also allows such a thing, but choosing it just because it's also written by Microsoft does not seem like a valid consideration here.

Mono DirectoryInfo for network share

I wrote a quick console app in VS2010 to copy a file from a network location to a specified location on disk. The program works fine on Windows but when I copy it into the Mac and execute it against the Mono runtime, it seems to have trouble opening the network share.
My code to create a DirectoryInfo object looks like this:
var dir = new DirectoryInfo(#"\\nameofserver\location\to\file");
In Windows, this resolves correctly to the network share. In Mac, it gives me a relative path to the binary (I was running it from the Desktop):
/Users/username/Desktop/\\nameofserver\location\to\file
I did Google it a little bit and it suggested that my path should be of the form smb://.... However, even when I do this, my DirectoryInfo resolves to:
/Users/username/Desktop/smb://nameofserver/location/to/file
I'm guessing there is either a syntax I'm missing to be able to get access to the network share or that it isn't so straightforward on OSX. Either way, I'd like to know how to connect to the network share and download the file.
Thanks!
EDIT:
I tried //nameofserver/location/to/file. This helped somewhat, except that it still did not resolve the network share reference, instead assuming the path to be a local one:
/nameofserver/location/to/file

C++ Program cannot see mapped drives

I am coding an unmanaged C++ console application on Windows 7 using Visual Studio 2010. I ran into an issue where files on my local computer or a network location work fine, but my code can't see anything on a mapped drive. I can simply this issue to a program that is the following 2 lines:
const WCHAR * libPath = _T("L:\MyFiles\myfile.txt");
DWORD fa = GetFileAttributes(libPath);
Where fa comes back as 0xFFFFFFFF, L is a mapped drive, and L:\MyFiles\myfile.txt is a valid text file.
How do I access mapped drives?
One possibility is that your application is running in elevated mode (ie. with Run as administrator selected). The problem is discussed in greater detail here.
The solution is to use net use to mount the drive or merge this into your registry:
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System]
"EnableLinkedConnections"=dword:00000001
Note that a reboot is required after making the above change.
This is a problem with Visual Studio. "Start without debugging" is NOT the same as running from explorer on Windows 7. The program works fine started from Windows Explorer. This is due to different UAC rights.

Resources