Question

I've been pulling my hair on this. I have a C++ OPOS driver that I wrote. I wrote in C# a virtual pinpad. It works and all is good.

One request that was given to me though is that the C# driver has to be present with the calling program. This took a while to figure out as we were expecting it to have to be where the OPOS driver is. Makes me think that I did something wrong setting it up.

I know that is vague, and that more information is needed, but I don't know where to start or what information you need to help out in this regard. I will check in often and answer any questions.... ugh i hate being this vague.. please don't flame :) I'll edit as much as needed.

EDIT

Sorry about not phrasing this very well. I had a lot going on when I was writing this. I re read it my self and was thinking "NEWB!" ha.

Ok, so down and dirty. The question isn't about the COM driver, the question is in the C# virtual pinpad. To sum up what i'm going to say is Why does my C# virtual pinpad dll have to be in the same location as my executable, and not the same location as my registered UPOS driver?

So to elaborate on that. The driver works (providing I don't mess it up again). As was pointed out it does have to be registered for any program to use it. All that is well in good. We put all the necessary files related to this UPOS driver in the same folder. At one point we had a C++ virtual pinpad that was built into the UPOS driver, but for simplicity I decided that it would be quicker and easier to just make a COM-visible C# virtual pinpad. And for the most part it was. It was nice because if i made any graphical changes I could just replace the VPP.dll and life was good. Then I went to install this set of drivers on a computer, and when i tried to open up the VPP it would crash. out of desperation I started copying the VPP.dll to different locations and found that when i put it in the same location as my executing program it would start working. This is not what i want. I want to be able to put it in the same directory as the rest of my drivers. (Which varies by environment, but in general is in the "Program Files" folder) Which brings me back to my summed up question above. It boggles my mind that my UPOS driver is the one making the COM call. When I do my install part of my install is putting the VPP.dll in the Program Files folder and running regasm on it (which says it was successful). So it just boggles my mind that it has to be with the executing program. Oh and another reason why it needs to be in the centralized location is that we have a few different programs (4 to be exact) installed in different locations. And Human error being what it is I don't want to have to copy the VPP.dll into potentially 4 locations on each computer. (which will end up being about 500 in the end)

so now that I clarified, (and actually asked a question..sorry about that), do we have any suggestions?

Was it helpful?

Solution

This kind of problem is a natural consequence of the way Windows (or the CLR, it isn't clear) locates dependent DLLs. The registration for a COM server only supplies the path to the DLL that implements the server. It doesn't otherwise affect the search path for dependent DLLs.

If this is a native (non .NET) DLL then Windows searches:

  • The directory from which the EXE was loaded
  • Optionally, the directory specified by a call to SetDllDirectory()
  • The Windows system directory, default is c:\windows\system32
  • The 16-bit legacy system directory, default is c:\windows\system
  • The Windows directory, default is c:\windows
  • The process' default working directory
  • The directories that are listed in the PATH environment variable

If this is a .NET DLL then the CLR searches:

  • The GAC
  • The directory from which the EXE was loaded
  • Optionally the probing path specified by the <probing> element in the app.exe.config file.

So clearly you'll have no problem if the dependent DLLs are located in the EXE directory. And a pretty nasty one if you want it somewhere else. Pick one from the above lists.

OTHER TIPS

So, you have a DLL (.net assembly) which implements the OPOS interface. OPOS interface is by spec a COM object (OPOS stands for Ole for POS).

I suspect that this is the requirement you have: Applications that uses your driver, whether native or managed has to be able to instantiate your object, via CoCreateInstance. In order to do that, your device has to be registered in the Windows Registry. See the example below for how to do that:

Note: You should be aware that newer standard called UPOS (Universal POS) has been developed, and Microsoft ".NET for POS" has support for it, which is also backward compatible with OPOS.

EDIT (following edits in the questions):
So it seems that your VPP is a COM object, and you have program registering it in a way that it is CoCreatable from any folder that is not the current directory. I suspect something is wrong with its registration. Make sure your COM object has a Porgram ID and a unique CLSID. Checkout the in the registry both HKCR\CLSID\<your object class id&> as well as HKCR\<your object progid>. Keep the UPOS and the application aside for a minute. Just make sure that a simple JavaScript file (xxx.js), with the line: var x = new ActiveXObject(<your prog id>) would work, when executing the script from any folder.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top