Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Interop / January 2005

Tip: Looking for answers? Try searching our database.

SQLMERGX, REPLERRX unable to get error messages

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Andreas Pircher - 10 Jan 2005 09:33 GMT
I use SQL Server Merge Replication in a C# Smart Client. Everything works
quite well until I try to get the information about occured errors.

First I tried to do it like every sample in the web does. I accessed the
ErrorRecords property of the merge control, checked the Count property of
that collection and if errors occured - loop through them in a foreach loop.
Doing so throws an exception that a cast to ISQLReplError is not possible
when entering the foreach-loop.

In my second approach I connected to the Notify-Event of the ErrorRecords
property. This gives me a notification with an error message for every error
that occurs - but somehow the interop marshalling seems to go wrong. In my
case (I have set a wrong database name to test errors) two errors are thrown
- in the first, the message parameter has a complete errormessage but with a
lot of nulls \0 at the end. When Notify is called the second time, the
message parameter contains only the first 20 or so characters of the error
message.
(VS 2003 crashes quite often when I set a breakpoint into this notify
handler ...)

I tried to customize the PIA to do "do-it-yourself-marshalling" with the
message parameter via an IntPtr but doing so throws an exception that no
Notifiy(..., string) is available.

Could someone give me a hint? Could I get the first approach to work somehow
and if not - could you point me to an explanation of how to customize this
PIA. (I have Adam Nathans .NET and COM here on my desktop but I was not able
to get that IntPtr customization to work - maybe because it is a callback?)

I was not sure wether to post this to sqlserver.programming or
sqlserver.replication or here but I hope this is the right place.

kind regards

Signature

luxbox.net, Andreas Pircher
http://www.luxbox.net

Andreas Pircher - 10 Jan 2005 13:57 GMT
This is the code I currently use:

try
{
    REPLERRXLib.SQLReplError  replError;
    for (int i=0; i < collErrors.Count ; i++)
    {
         replError = (REPLERRXLib.SQLReplError) collErrors[i+1];
         alErrorRecords.Add(new
ReplicationErrorRecord(            replError.Description,                         replError.ErrorNumber,
                    replError.ErrorNumberString,                     replError.Source));

    }
}
catch(Exception ex)
{
    System.Diagnostics.Debug.WriteLine(ex.Message);
}

REPLERRXLib and SQLMERGXLib are the original files that are produced by
VS2003 when I add a reference to the corresponding COM Objects.
At this line
         replError = (REPLERRXLib.SQLReplError) collErrors[i+1];
an exception is thrown - the Message is "Interface not registered" (on my
maschine it says "Schnittstelle nicht registriert" - the german error message)


kind regards

--
luxbox.net, Andreas Pircher
http://www.luxbox.net
"Peter Huang" [MSFT] - 11 Jan 2005 09:02 GMT
Hi

I am not familar with SQL programming, based on my research, I did not find
that we have an official Primary Interop Assembly(PIA), do you mean the two
dll generated by the VS.NET IDE when you add a COM Reference to the two COM
library.

It is possible that the generated Interop Assembly may have some flaw which
will cause the problem. So far I think you may try to use the reflection to
do the latebinding, so that we do not need to do the type convert.

Here is a link about how to invokemember to do latebinding with COM Object.
303296 How To Use Automation to Get and to Set Office Document Properties
with
http://support.microsoft.com/?id=303296

Best regards,

Perter Huang
Microsoft Online Partner Support

Signature

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Andreas Pircher - 11 Jan 2005 11:35 GMT
Thank you - I got it to work within 15 minutes - and I learned something.

kind regards,
Andreas Pircher, luxbox.net

> Hi
>
[quoted text clipped - 19 lines]
> Get Secure! - www.microsoft.com/security
> This posting is provided "AS IS" with no warranties, and confers no rights.
Andreas Pircher - 11 Jan 2005 11:41 GMT
And yes - I was talking about the VS generated dlls.

> Thank you - I got it to work within 15 minutes - and I learned something.
>
[quoted text clipped - 24 lines]
> > Get Secure! - www.microsoft.com/security
> > This posting is provided "AS IS" with no warranties, and confers no rights.
"Peter Huang" [MSFT] - 12 Jan 2005 05:55 GMT
Hi

Thanks for your quickly reply!

I am glad that my suggestion help you.

Best regards,

Perter Huang
Microsoft Online Partner Support

Signature

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.