Showing posts with label method. Show all posts
Showing posts with label method. Show all posts

Monday, March 19, 2012

Msg 6573 - method in assembly is not static - how do I make it static ?

I'm using Delphi 2006 to create a DLL which will be integrated into SQL 2005. It's been a long road and I've made a lot of headway, however I am currently having the following problem creating the stored procedure:

My dll name is 'Crystal_Reports_Test_01'
In the DLL, my class is named 'Class01'.
In the DLL, my procedure is named 'TestMe'

I've managed to integrate the DLL into SQL using the following statement:

CREATE ASSEMBLY TEST_ERIC_01
AUTHORIZATION dbo
FROM 'c:\mssql\assemblies\crystalreports.dll'
WITH PERMISSION_SET = UNSAFE


I am attempting to create the stored procedure which points to the 'TestMe' method inside of the DLL. FYI: 'CrystalReports' is the namespace above my class that I had to add in order to get it to locate the class. The following code is used to create the stored procedure:

create procedure dbo.Crystal_Reports_Test_01(
@.Parm1 nvarchar(255)
)
as external name TEST_ERIC_01.[CrystalReports.Class01].TestMe


But I get the following error:

Msg 6573, Level 16, State 1, Procedure Crystal_Reports_Test_01, Line 1
Method, property or field 'TestMe' of class 'CrystalReports.Class01' in assembly 'CrystalReports' is not static.


I'm not sure what this means exactly. I think it means the method (the procedure) is not using Static method binding but should be. I have no idea what this really means or how to accomplish this in the DLL - or if I'm even going about this in the right way.

Any help would be appreciated ! I'll post the Delphi code (DLL) below.

Thanks,

Eric Gooden

library CrystalReports;
uses
System.Reflection,
System.Runtime.InteropServices;
...................
type
Class01 = class
public
procedure TestMe([MarshalAs(UnmanagedType.LPWStr)] var sVarString: wideString); export;
end;

procedure Class01.TestMe([MarshalAs(UnmanagedType.LPWStr)] var sVarString: wideString); export;
begin
sVarString:= 'Lets change the value and see if the stored proc. gets the change.';
end;

end.

I've not actually used Delphi.NET, but after a quick look it seems like to make a static method you have to declare your function like so:

class procedure TestMe([MarshalAs(UnmanagedType.LPWStr)] var sVarString: wideString); export; static;

Hope this works.

|||Yeah, I tried to add the static at the end of the declaration before and the Delphi compiler didn't like it (said "STATIC can only be used on non-virtual class methods"). Which confuses the heck out of me because the Delphi help on Static Methods says that Methods are static by default. And from what I gather, you'd have to add the keyword virtual to specify a non static method.

I may also post in a Delphi forum to see what I come up with. I would have done this originally, but I wasn't sure if it was a problem in my Delphi code or maybe a setting on SQL Server that I might have to tweak.

Thanks,

Eric Gooden
|||Steven, I have to admit that once first viewing I did not notice the keyword Class prefixing the procedure declaration. Adding this prior to the procedure declaration did the trick. After that, Delphi would allow me to define it as static. Thank you very much for your help !

Eric Gooden

Wednesday, March 7, 2012

MSDTC resource in a Cluster

I've read and heard some conflicting information about the best method for
setting up a MSDTC resource in a cluster. I am running MSSQL 2000 SP3a and
Windows 2003. 2 node cluster with currently only once instance of MSSQL
with a great chance of growing.
A few questions I have:
Should the resource be in the cluster group or the virtual server group?
What else does it need, ip address, name...?
If it's not yet being used, is it safe to have it on the quorum drive
(currently 1GB RAID1)?
Has anyone found a white paper specific to Win2k3, MSSQL2k and MSDTC?
Thanks,
Joseph
Hi,
I've found this paper
http://support.microsoft.com/default...b;en-us;301600
It suggests to put MSDTC in its own group with its storage resource(disk).
On other hand if that is not possible you can put it in a group with disk.
Anyway I would mess with quorum drive, so I would put it in a Virtual Server
group.
Danijel
"Joseph" <Joseph@.discussions.microsoft.com> wrote in message
news:OEv$n4M%23EHA.2552@.TK2MSFTNGP09.phx.gbl...
> I've read and heard some conflicting information about the best method for
> setting up a MSDTC resource in a cluster. I am running MSSQL 2000 SP3a
> and
> Windows 2003. 2 node cluster with currently only once instance of MSSQL
> with a great chance of growing.
> A few questions I have:
> Should the resource be in the cluster group or the virtual server group?
> What else does it need, ip address, name...?
> If it's not yet being used, is it safe to have it on the quorum drive
> (currently 1GB RAID1)?
> Has anyone found a white paper specific to Win2k3, MSSQL2k and MSDTC?
> Thanks,
> Joseph
>
|||The official best practice is "put MSDTC in its own group" but to do that
you will need an extra disk, Network Name and IP Address.
Unless you know you will be hitting MSDTC hard, like in a BizTalk
environment for example then leave it in the cluster group. In the event of
an MSDTC failure the Cluster Group will failover to the passive node. The
only "outage" will be for admin's connected to the Virtual Cluster Name in
Cluster Administrator as the resources are re-started on the new node. It
will not affect any other groups.
Alternatively, if MSDTC was in the SQL Group then a failure would cause a
SQL Server outage. If your application is entirely dependant on MSDTC, this
might be fine but its more likely that you wouldn't want that to happen.
You can set MSDTC to not affect the group but then you don't have the
benefit of failover.
In summary, leave MSDTC in the Cluster Group. It makes sense and we support
it
Christian Bolton
Microsoft
"Danijel Novak" <danijel.novak@.snt.si> wrote in message
news:nVfFd.8296$F6.1420730@.news.siol.net...
> Hi,
> I've found this paper
> http://support.microsoft.com/default...b;en-us;301600
> It suggests to put MSDTC in its own group with its storage resource(disk).
> On other hand if that is not possible you can put it in a group with disk.
> Anyway I would mess with quorum drive, so I would put it in a Virtual
> Server group.
> Danijel
> "Joseph" <Joseph@.discussions.microsoft.com> wrote in message
> news:OEv$n4M%23EHA.2552@.TK2MSFTNGP09.phx.gbl...
>