The process executed with the extension does not find the path to the referenced dll - dll

The process executed with the extension does not find the path to the referenced dll.
It was normally used when it was executed with ".exe".
However, after running with the extension registered in the registry, trying to use the dll results in an error that the dll file cannot be found.
If you look at the content of the exception that occurred, the dll in the path of "C:\myfolder\myDll.dll" try to find to "c:\Windows\system32\myDll.dll".
How do I do anything other than put it in the System folder to ensure that the extension-enabled process recognizes the path in the dll ?
It is not possible to put it in the system folder, so another method is needed.
p.s ) When i open a process by right-clicking an icon in the taskbar while the process is floating, the newly opened process also generates the same invalid dll path error.

I fixed it.
it cause that "System.Environment.CurrentDirectory" and "AppDomain.CurrentDomain.BaseDirectory" were different.
so when Application start, Check each directory and change it if it is different.
my case in WPF, System.Environment.CurrentDirectory was Windows System folder.

Related

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.

regsvr32 Custom ocx file not Registering

I've been asked to install an old VB program on an XP computer, but when I do I get an error when I run the program saying that Component 'filename.ocx' or one of its dependencies is not correctly registered: a file is missing or invalid.
This is a custom file (I did not create it), I have tried regsvr32 and I get no error messages but no successfully registered messages either.
This program also runs on another computer which this ocx file is not registered but opens without error. So my question would be what could cause the file to not be recognized by regsvr32, and run on another client with the same os, but without error. Any ideas, or new paths to look into would be very helpful.
Also if you dislike something about this question, let me know what it is, so I can fix it in the future. Down voting a question gives me no insight on why this upsets the community, it just discourages me to want to help others in areas I do understand.
If you do get the error "Component 'filename.ocx' or one of its dependencies is not correctly registered: a file is missing or invalid" from a custom dll or ocx file, it may just need that file and its dependent files in the directory that your running the executable, as was the problem in my case.
After adding the file to the root directory, and not registering any files the program opened fine. Maybe this helps someone else.

Reference VB.NET DLL in Kofax Document Validation Script

We are working on a validation script for Kofax Capture 9.0 / 10.0 in VB.NET 3.5.
We know how to create a script using the Admin Module, and how to get it operational.
The problem is that we need to reference a dll, located on a remote machine. (GAC is no option) This dll holds abstract classes we need in each validation script.
Even when putting the dlls locally (copy local), the Validation Module (index.exe) immediately throws the "cannot find reference" exception, even though the project compiled perfectly.
I guess the basic question comes down to: where do we put the dlls, in order for the Validation Module to find them?
The simple answer is to put the dll in the same folder as the application because this is one of the places which .NET will probe when trying to find it. The Validation module is run from the Capture bin directory which will be something like "C:\Program Files (x86)\Kofax\CaptureSS\ServLib\Bin\". This would need to be done on each client using Validation.
If you have a more complicated scenario, you could look implementing the AppDomain.AssemblyResolve Event and using Assembly.LoadFile to get the assembly from a custom location, but the using the bin path is less complicated.
If you end up having further trouble, you can troubleshoot by using the Assembly Binding Log Viewer (Fuslogvw.exe) which can tell you more details about why the assembly failed to load and where .NET tried to search for it. Assembly loading can fail for reasons other than just the path.
For more detail on how .NET loads assemblies, see the following:
How the Runtime Locates Assemblies
Locating the Assembly through Codebases or Probing
We found a solution: add all library files as "links" to the project. (Add --> Existing File --> small arrow next to "Add" --> Add as Link)
This ensures the files are compiled when you build the project. The Kofax Validation Module can now find the files, whereas when referencing the file, it could not. Why it could not, remains a mystery...

Problems registering a dll

I am trying to register a .dll file but I am getting an error. The .dll is in the SysWOW64 folder, through the command line I then cd \Windows\SysWOW64 and run the following command regsvr32 php_sdo.dll
I then get the following error:
"The module "php_sdo.dll" failed to load.
Make sure the binary is stored at the specified path of debug it to check for problems with the binary or dependent.DLL files.
The specified module could not be found"
This kind of failure often occurs when one of the dependency of the DLL one wants to register (which physically means, that the program that attempts to register the DLL internally calls LoadLibrary) is missing. You can have a look at the dependency (tree) of your DLL using Dependency Walker.

How to access a temporary Exe or DLL from a DLL Custom action (C++ DLL) in MSI/WIX project?

I have two use cases: 1) loading a temporary DLL during a custom action and 2) executing a temporary EXE from a custom action. The custom action DLL is unmanaged C++. I cannot figure out how to get this working correctly. Including the DLL is easy enough but LoadLibrary is failing as it cannot find the DLL. I also cannot seem to get the physical path of the extracted DLL in order to specify full path in LoadLibrary. Any help is appreciated. I'm using WIX btw for this work.
If you have included the dll and the exe in the Binary Table of the msi, the files will be physically present in the %Temp% folder of the currently logged in user which gets mapped to SUPPORTDIR property of Windows Installer.
You need to use MsiGetProperty to get the SUPPORTDIR and use that in the LoadLibrary.
One thing to remember - Windows Installer usually extracts files from Binary table to %TEMP%, however - the current work directory is often set to c:\windows\installer.
My suggestion - extract the temporary .dll from Binary table yourself when you need it. This gives you the control of when it's saved to. Just remember that you need write permission to the location, so usually some subdir of %temp% is the best choice.