Problems with running WMV in VB.Net - dll

I just finished building my program, but I noticed that vb.net (2010) creates two dll files ( AxInterop.WMPLib.dll & Interop.WMPLib.dll ), when I tried to run the application without having those two files in the same directory, it crashed right away!!!
Is there a way, to have the WMV components running without using any additional libraries, so I can distribute the exe file only?!!!
Thanks

I used a program called smartassembly, to protect the source of my program.
The program itself asked me if I want to merge dependencies (resources), so I picked the two dll files, and it me out one executable file, with no dll files at all.

Related

Why does this explicitly-linked DLL delegate succeed in one program but not another?

I have 2 programs which share a project in which an API DLL is used to perform actions on files in another directory. The problem that I have is that this code works in one project, but in the other it fails:
moduleHandle = LoadLibrary(“api.dll”)
Earlier on, the program that fails failed to connect to the API DLL here so after comparing the Process Monitor logs of both I copied some DLLs into the same directory as it. It then succeeded, and the values of moduleHandle are now the same in both programs. Next:
methodPointer = GetProcAddress(moduleHandle, "NameOfSomeFunction")
delegateForSomeFunction = Marshal.GetDelegateForFunctionPointer(methodPointer, GetType(SomeFunctionType))
When we get to the delegateForSomeFunction, I can see that the value of _methodPtr in them is different from one program to another. Then when we get to invoking the delegate:
Dim argsArray() As Object = New Object() {directoryPath, errorFilePath}
Dim retVal As Short = delegateForSomeFunction.DynamicInvoke(argsArray)
In one program this just fails silently. I'm at a bit of a loss as to how to proceed. What should I do to investigate this further and how can I get it to work?
I’m running this on debug in Visual Studio 2013, and the project is in .NET 4.
Although copying the correct versions of dependencies from winsxs into the same directory of the API DLL did allow me to perform LoadLibrary without obvious errors, it caused more errors in the background.
The problem was in the manifest in the end. There was a post-build event that removed the manifest from the .exe in preparation for a deployment step that allowed you to specify different versions of the API present. Creating a proper appname.exe.manifest file specifying the dependent assemblies that I was failing to load normally, and then placing this into the same directory as the .exe, solved the issue.

Is File.Open directory behavior different in x86 vs x64

I am working on a application built in VB.Net that allows a document to be uploaded and saved into a database. I did not build this application, but I do maintain it, put enhancements in it here and there. The target framework is .Net4
One of the functionalities within this process when uploading and saving the document it uses the method File.Open() to access the file and run other methods to compress it. The method that uses File.Open takes in a parameter that passes just the filename, not the entire path of where it came from.
When this application is running on an x64 machine I receive an error (System.IO.FileNotFoundException) when the code hits the File.Open method, complaining that it cannot find the file to open. It is expecting the file to be in the programs executing directory, which does make sense because it is only given the filename to go off, not the entire directory that it came from.
What's getting to me, is that this exact same application (exact same built assemblies) will run fine when run on an x86 system. It does not fail on File.Open() It still passes just the filename, but somehow, it will know the directory information.
How is this possible?
It's worth noting, that the method that contains the File.Open() method is in a different project in the same solution. It's a referenced DLL. e.g. MyApp.exe (Windows Form Application) references MyUtil.dll (Class Library). I have built against x86, x64 and AnyCPU configurations.
I understand that the fix to this would be to just pass the entire directory to the method, but what I need to know is how this is even possible? I want to better understand why this would happen, and hopefully this would help someone else better understand how assemblies may differ between different system environments.
EDIT: Using an absolute path did fix the underlying issue. See the comments below for some good information on this scenario
Windows has special handling for certain folder names on 64bit systems depending on whether you have a 32bit or 64bit process. Notably, the Program Files folder and the System32 folders map differently depending on what kind of process you have.
Note that this is a difference in Windows itself. It's not a behavior that is unique to .Net or Visual Basic. Any program platform that uses Windows native file handling will give you these results.
This is why you should use appropriate relative paths or the SpecialFolders enumeration, rather than hard-coding full path names, and be careful about where you put things you expect to reference later; you might find they end up in a different location than you expected. Often, the AppData or ProgramData folders are the more correct location, instead of the Windows or Program Files folders.

Determine which .dll (.tlb) running

My .exe contain a lot dlls added through reference or as .CreateObject .
I wonder is there any way when i open some dll to find in processes or somewhere else which .dll is currently in use
Just use Process Explorer from sysinternals by truning on View->Lower Pane View->DLLs (Ctrl+D) and then clicking on your application process in processes list.
With Find->Find Handle or DLL (Ctrl+F) you can search for DLLs and other files being open by any system process, e.g. when you need to delete a data files but the OS refuses for file being in use reason and not telling you which one the culprit is.

VB.NET include .exe in project and attach to main process

I have a VB.NET project (main.exe) and include an additional .exe application as internal resource. Now I do not want to run the extra .exe as a separate process but want to attach it to the process of main.exe so I have just 1 process overall and not 2.
Can this be done somehow?
Thanks
The solution is to compile the additional.exe as .dll and use it in VB.NET

Include executable in another executable

Can I include an .exe file in another, and then run it from the outer program?
For instance, can I make a wget GUI by including it inside my program, or are my only options either using the including the source or supplying the wget binary together with my wrapper?
I am working on Windows and am looking for a solution in c/c++/c#
Sure you can.
The idea is to 'insert' the exe as a resource to you main application.
There is a link which explains how to compile resources into delphi exe. Its similar to VC++ or what ever...