Legacy activeX control calls DLL functions - I need help - asp.net

Hint: this one might sound complicated, because I am trying to give as much info as possible, but I suspect that I just want someone to tell me "yes, you are correct".
On this legacy system, which dates from 2002, the user visits a web page and uses an RFID reader to read a tag number, which is then written to an input field on the web page.
The only s/w that comes with the reader is a custom DLL, nop .exe.
The very sparse documentation insists that only MSIE be used and that all security relating to ActiveX be disabled.
When I look into the source of the web page I see calls to functions in the DLL.
Now, here's the fun part: I know zilch about ActiveX, I have to make a minor change to the DLL *but* the VB6 source code has been lost, so I guess that I have to recreate the (seemingly very simple) DLL from scratch - this week.
Decompiling the DLL shows me the functions (locateReader, getTagVal, closeReader). However, by decompiling I can't really know the number or type of the parameters, nor the return values ... and if anyone knows the API they are refusing to share it, but basically it all seems to have been lost in the mists of time as companies went bust, were bought & sold, merged & demerged and the initial DLL might have been written by an external guy, but no one knows who.
So, can I get the function params & type from the ASP page source?
I see things like
Reader = new ActiveXObject("<dllName>.Reader");
Reader.locateReader();
tagVal = Reader.getTagVal();
Reader.closeReader();
So, I would say that none of the fn()s take parameters, that closeReader doesn't have to return anything; it looks like locateReader doesn't return anything either, so I guess that error handling will have to be in the DLL (loop forever with a popup demanding that a reader be attached; and getTagVal seems to return a string.
Does that sound about right? Any other comments (other than lessons to be learned)?

The 'code' you've put here looks like the a direct call to the device. And getTagVal() seems to get the RFID value? Since this is an COM (Active X) call can you call this in a simple .net program and see if you can access the reader? If you can then you may be able to just wrap the existing functionaliy in your wrapper.
You need to try and generate a TLB from the component:
So, if you only have a COM dll, you
need to get an idl-file from it:
Visual Studio, start it and go to the meny Tools->OLE/COM Object Viewer.
This is called oleview.exe and can also be got from the windows sdk
In that application, select meny File->View Typelib..
Select the COM dll and you will see the Typelib.
Select the meny File->Save as. Save it with an appropriate name. For
example "mycom.idl"
start midl.exe or mktyplib.exe with the idl-filname as the argument. "midl
mycom.idl"
Read MSDN for more info about midl and
mktyplib

Related

Is there an ObserveOnDispatcher for Windows Store Apps?

I'm using reactive extensions (well, trying, learning) in a windows store app. I have a series of async operations that will eventually navigate to an authorization web page for RTM. Given the reading I've done, I would expect to write something like the following:
var result = rtm
.GetFrob()
.Select(s => rtm.GetAuthenticationUrl(s))
.ObserveOnDispatcher()
.Do(uri => AuthWebView.Navigate(new Uri(uri)))
.First();
However, I can't seem to find a method ObserveOnDispatcher, and further there is no Scheduler.Dispatcher property either, leading me to think on a Windows Store application there is something deeper gong on with the main UI thread and how you reference it.
GetFrob, btw, creates an IObservable sequence using Observable.FromAsync (if that helps with this).
BTW, if I remove that line, I fail in the call to the Navigate as posting it from the wrong thread. So, what is the proper thing to do here to make sure I'm back on the correct thread?
BTW, Excuse the ".Do" operation here, I know it isn't "nice", however, I'm still experimenting in throw-away code.
Many thanks in advance!
Argh. Apparently I just am not good enough at search. :(
Turns out that adding the nuget package Rx-Xaml includes the proper assemblies for the scheduler, etc. Details can be found on the main Rx blog. Of course, my app is back to hanging now, but that may be due to something else dumb on my part.

resx resources or database for globalization resources

I have been trying to get culture specific resources to work on an asp.net mvc 3 application.
If I have a LanguageResources.resx and a LanguageResources.en-UK.resx in my App_GlobalResources folder then I get an error "The namespace 'Resources' already contains a definition for 'LanguageResources'"
This is the end of a long line of issues that I have had with trying to get culture specific resources to work. I must say, I'm not impressed with the documentation Microsoft provide for using this feature.
I'm considering using a database table to store my culture specific strings instead, then I can just build a dictionary of all the values that will be available to my controller and views.
Has anyone else made such a decision, or have any direct knowledge on performance issues related to using a database for culture specific strings?
Has anyone else given up on resources too?
I must admit, I tried to reproduce your defect and I was successful. It looks like, Visual Studio generates additional class when you add something.en-UK.resx. Strange. It should not allow you to add anything like this in the first place for there is no such culture.
How to resolve the problem? Just add LanguageResources.en-GB.resx and delete
LanguageResources.en-GB.resx. That helps.
I would not use database for storing language-related resources, unless they are changing very frequently or must be entered by end users (i.e. there are some kind of templates).
Using the database hurts Localizability and requires much effort. It is hard to design correctly (I have seen a lot of mistakes in that area). Don't go that road unless you really have to.

ASP.NET Printing (MVC) Word Documents In SharePoint

So I have our MVC web application up and running and we'd like to introduce printing into the solution. We have an interface (using SharePoint Service 3.0) that displays many files (all Word files) for a particular product. What we'd like to have happen is for the user to checkbox all the files they want to print, select a printer, and go at it.
The checkbox implementation is easy, I'm trying to think of a good print solution (if there is any). I'm looking for "out of the box" type solutions. One thing I was thinking about was creating a web service on SharePoint that takes all the files selected, merges them (somehow), and temporarily posts one big doc that, when finished, the client will print, and then the document gets purged. Not exactly the fastest operation but seems like it could work.
What's your thoughts on an implementation?
What kind of Doc Files do you have?
Are they already in the DocX format?
If so you can merge them quite easy with the documentAPI

RDS Replacement in Classic ASP and How to Do the same in .NET

We have an application that makes heavy use of the RDS.Dataspace.
As in :
set objDS = CreateObject("RDS.DataSpace")
set objJB = objDS.CreateObject("JBdbio.dbio","http://<%=Request.ServerVariables("SERVER_NAME")%>")
To instantiate and then:
NewQry 2,"QryUpdtItem" ' To set the name of the stored procedure
AddParam 255,"ISBN",200,txtISBN.value 'params
AddParam 255,"Titl",200,Title.value
m = objJB.UpdateQry(arrPrm) 'do the call to execute the stored procedure
Some do updates, some selects, etc
With RDS now obsolete for a number of years. How can I keep my asp code and have a Dataspace to attach to my business object (JBDBIO).
Essentially we just pass all of our params and stored procedure to this business object and then just dish up the results.
And if I were to move this to .net - how could I do the same without ajaxing it -- this is all vbscript code that runs, in effect an application within IE
Its time for a complete redesign. VBScript in IE is just not something that you want to be taking forward.
If you still want to use the browser as a means of delivering an inhouse UI then consider ASP.NET-MVC. If you want to attempt to make the UI smooth in the browser then inclusion of AJAX is the direction you need to take.
OTH in your case it may be worth you considering the delivery of the UI in a non-browser medium. For example a Silverlight3 using Ria services may be a way forward, XBAP or Click-once installs may also be an option.
No matter what choice you make its going to be a steep learning curve to move away from ancient RDS/VBScript in the client. You may as well take the opportunity to re-visit the UI behaviour as well.
You said it "flickers" on postbacks in the page your guy had rewritten to ASP.NET, didn't the old version "flicker" on postback (submit)? And wow did the .NET code look like if you have not already found any .NET replacement for the database code?
Or have I not understood right, is the VBScript you are talking about client side VBScript? In that case you can actually use the old client side VBScript in the .NET page as well (just as you can run JavaScript on the client side).
If this does not point in any direction to a sollution, I think you might have to provide some more details with code examples, and what you want to acheive.

Suppress MessageBox from a referenced assembly

How do I suppress a MessageBox from showing that comes from a reference to an assembly that I do not own (nor have the code for)?
For example, my application (MyApplication.exe) is referencing an assembly coded by someone else (SomeoneElsesAssembly.dll). Inside of this assembly I'm calling a static method, which does what it's supposes to, but also is firing a MessageBox that I want to suppress.
I thought there was a way to reference an assembly in Non-Interactive mode or something along these lines.
Thank you for your help.
-Jessy Houle
This article may be able to help
What you are asking is basically "How can I modify the behavior of code in a third-party assembly".
Short of disassembling/reassembling, the answer is "You can't".
There are some icky options;
With managed code you always have the source in some form. If the function is somewhat self-contained you could use Reflector to copy it into your own code
You could have a 2nd thread that waits till the message box appears and then automatically closes it.
I thought there was a way to reference an assembly in Non-Interactive mode or something along these lines.
I believe it's possible to run a process in a non-interactive mode (such as Windows Services, for example), but assemblies are loaded into the process and are subject to the same interaction levels as other assemblies in the process, afaik.
So, either disassemble-reassemble or send windows messages directly to the box to automatically close it.
Basically you're asking if you can reference an assembly which calls MessageBox() and have the code not actually show a message box. The answer is unfortunately no.
You're best bet is to use screen scraping to close the message box once it shows up. This post has some example code of how to close an InProc message box. http://www.codeproject.com/KB/dialog/AutoCloseMessageBox.aspx

Resources