Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Visual studio .NET integrated windows installer : self registering of a dll (vsdrfCOMSelfReg)

Posted on 2003-11-26
23
Medium Priority
?
1,863 Views
Last Modified: 2007-12-19
In my application I use SQLDMO to have acces to the same possibilities as in the SQL Enterprise Manager (sqldmo.dll)
My application must run on PC's with already MSDE/SQL Server installed or PC's without MSDE/SQL Server installed (even no installed SQL Client software).
Microsoft has a knowledge paper with the steps to follow what to install for being able to run SQLDMO on a client machine without SQL client software.
You must install several dlls and one dll (sqldmo.dll) must be registered.
In a windows installer project (Visual Studio .NET) you can set the proporty REGISTER of this dll to vsdrfCOMSelfReg.
After running my installer my application was running on all machines (it worked  :-) )
But there is a 'BUT' :
The installer is not detecting that the dll is already installed and registered on machines with SQL Server. It will overwrite the existing settings and if my application is removed, the Enterprise Manager for example will not work anymore because the sqldmo.dll is not registered anymore (the deinstaller removed the registering...)

How do I tell the installer to not register the dll if this dll is already registered. It must only register the dll on 'clean' machines.
I'v searched already the net for an answer, but no luck for the moment...
0
Comment
Question by:ericvb
23 Comments
 
LVL 12

Expert Comment

by:roverm
ID: 9824274
What about installing all DLL's WITHOUT registrating them using a ProjectInstaller, then write some code in the 'AfterInstall' event to check whether that 1 dll is already registrated. If not: run regsvr32.exe to register it.

D'Mzz!
RoverM
0
 

Author Comment

by:ericvb
ID: 9824309
Yes, I thought about it also, but how do I test if a dll is already registered?
Till now I didn't find a line of code in C# to test this.
I could also look manually in the registry, but is there no other way, using the .NET environment, for example?
I didn't find anything in the MSDN library, but I'm overlooking it maybe
0
 
LVL 12

Expert Comment

by:roverm
ID: 9824320
I think (*know*) it can be done using some API's. But I don't have my api collection here.
I can take a look for you this evening it you want.
0
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 

Author Comment

by:ericvb
ID: 9824334
I should be gratefully if you want to do this.
I know also that it must be possible, but I do not find it for the moment :-((
It drives me crazy, it looks so simple...
0
 
LVL 12

Expert Comment

by:roverm
ID: 9827819
Ok, I looked for the api and I guess I was wrong. At least, I can't find it ;-)
However, I got another idea.

I am building a 'registry scanner' which scans for the dll.
Got it all working except for the last stage...the reading of the value.

Still working on it ;-)
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 10277253
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:

PAQ with points refunded

Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

TheLearnedOne
EE Cleanup Volunteer
0
 
LVL 12

Expert Comment

by:roverm
ID: 10278697
Woah, forgot on this one. Do you still need a scanner?
0
 

Author Comment

by:ericvb
ID: 10278763
Yes, of course  :-)
The problem is still there, I didn't find a solution.
I must admit, that I putted this problem aside, didn't have the time to put more time in it.
0
 
LVL 12

Expert Comment

by:roverm
ID: 10279528
Ok, I've build it for a great part, I only need to finish it...
0
 
LVL 1

Expert Comment

by:Computer101
ID: 10337537
PAQed, with points refunded (200)

Computer101
E-E Admin
0
 
LVL 12

Expert Comment

by:roverm
ID: 10340040
Computer101, please read the last 2 comments. I was still working on this one!

ericvb, do you agree to open the question?
0
 

Author Comment

by:ericvb
ID: 10341888
I agree to let this question open
0
 
LVL 12

Expert Comment

by:roverm
ID: 10360652
ericvb, it seems that C101 has forgotten about us.
I can reopen this question as well. Do you remember how many points you set on it? Then I can set it again.
0
 
LVL 12

Accepted Solution

by:
roverm earned 800 total points
ID: 10360718
eric, this is what I have so far.

I've build a recursive function which will scan for the registry key.
This works just fine and is even quit fast (depending on your computer of course).
However, I can NOT access the last value of a key. Didn't find that yet.
But posting this anyway, so you can try as well.

You need to import this:

Imports Microsoft.Win32.Registry

Then the function:

    Private Function SearchKey(ByVal strStart As String, ByVal strSearchFor As String) As String
        Try
            Dim ky As Microsoft.Win32.RegistryKey = CurrentUser.OpenSubKey(strStart, False)
            If ky Is Nothing Then Return ""
            Dim arr() As String = ky.GetSubKeyNames()
            Dim arrd() As String
            Dim arrValues() As String
            Dim strResult As String
            Dim kyval As Microsoft.Win32.RegistryKey
            Dim i As Int32 = 0
            If arr Is Nothing Then Return ""
            If arr.Length = 0 Then
                arr = ky.GetValueNames()
                If arr.Length > 0 Then
                    kyval = CurrentUser.GetValue(ky.Name)
                End If
            End If
            For Each strKeyName As String In arr
                If strKeyName.ToUpper = "CLSID" Then
                    'Stop
                End If
                ky = ClassesRoot.OpenSubKey(strStart & "\" & strKeyName, False)
                If Not ky Is Nothing Then
                    arrValues = ky.GetValueNames()
                    For Each s As String In arrValues
                        'If s = "" Then s = "(Default)"
                        kyval = CurrentUser.OpenSubKey(strStart & "\" & strKeyName & "\" & s, False)
                        If Not kyval Is Nothing Then arrd = kyval.GetSubKeyNames()
                    Next
                    i = arrValues.IndexOf(arrValues, strSearchFor)
                    If i > -1 Then
                        Stop
                        Return "Found It!"
                    End If

                    arrValues = ky.GetSubKeyNames()
                    For Each strSubKeyName As String In arrValues
                        If strSubKeyName.ToUpper = strSearchFor.ToUpper Then
                            Stop
                        End If
                        strResult = SearchKey(strStart & "\" & strKeyName & "\" & strSubKeyName, strSearchFor)
                        If strResult <> "" Then
                            Stop
                            Return "Found it!"
                        End If
                    Next
                End If
            Next
        Catch ex As Exception
            Stop
        End Try
    End Function

Finally, to call it:

SearchKey("AppEvents\EventLabels\AppGPFault", "sqldmo.dll")

As you can see, pass the start key and what to search for.

Let me know what you think.

D'Mzz!
RoverM
0
 

Author Comment

by:ericvb
ID: 10370004
Hello RoverM,

Computer101 said : 'PAQed, with points refunded (200)', so I suppose that I setted it to 200 points? I don't know it anymore....

Thanks for your function, I will test it and let you know if it helps me.
(It will take me, maybe, some time, because I'v never worked with VB : must translate to C# or include this VB code in C# (I know it is possible, but did never do this before...))

Thanks,
Eric
0
 
LVL 12

Expert Comment

by:roverm
ID: 10370258
Else add a VB module or class to your project.
Then you can copy/paste it into that and call it from C#.
0
 
LVL 12

Expert Comment

by:roverm
ID: 10463377
Eric, any progress?
0
 

Author Comment

by:ericvb
ID: 10463498
Sorry Roverm,

I did not have the time yet to test your solution and I don't know if I shall have the time in the weeks to come.
The company who I work for is taken over by another company, so I must know spend my time to coordinate this takeover.

I know that you have administrator rights, so I propose that you take already 50% of the points on your count.
I thank you very match for your help, and I hope to test your solution soon.

Regards,
Eric
0
 
LVL 12

Expert Comment

by:roverm
ID: 10463849
Hi Eric,
No need to apologize.

I'm sorry to say that I don't longer have admin rights (I am no longer the PE of .NET) but even if I had then I wouldn't have done that.
Let's wait and see when you have time again.

Good luck with the take over.

D'Mzz!
RoverM
0
 

Author Comment

by:ericvb
ID: 10956649
Hi Roverm,

I didn't have the time yet to test your solution, but as thank for answering my question, I will give you the points.

Thanks,
Eric
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Screencast - Getting to Know the Pipeline

886 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question