Showing posts with label static. Show all posts
Showing posts with label static. 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

Monday, February 20, 2012

MSDTC

Hi all,
I'm new to clustering. Just some question to ask u all.
Do we have to configure separate static ip, network name and physical disk
for the MSDTC?
Or we can use the same static ip, network name and physical disk(Q:quorum
disk) that we configure for server clustering?
Appreciate ur help.
Tks
Message posted via http://www.droptable.com
Current best practice recommendations from Microsoft say to put MSDTC in its
own virtual server. therefore you will need a static IP addres, network
name, and physical disk. It is possible to use the Quorum disk and group
but it is not recommended. If you expect a low volume of Distributed
Transactions, you should be OK sharing one device.
Geoff N. Hiten
Microsoft SQL Server MVP
"Mohd Hidayat via droptable.com" <forum@.nospam.droptable.com> wrote in
message news:947e91d07767474e88186ebbb5ed1539@.droptable.co m...
> Hi all,
> I'm new to clustering. Just some question to ask u all.
> Do we have to configure separate static ip, network name and physical disk
> for the MSDTC?
> Or we can use the same static ip, network name and physical disk(Q:quorum
> disk) that we configure for server clustering?
> Appreciate ur help.
> Tks
> --
> Message posted via http://www.droptable.com
|||Mohd
It is recommended to create a new group with disk, ip, and name resources
available for the MSDTC resource. It is acceptable to use an existing group
if you do not have the resource capasity.
http://support.microsoft.com/default...b;en-us;301600
Regards
CT
"Mohd Hidayat via droptable.com" wrote:

> Hi all,
> I'm new to clustering. Just some question to ask u all.
> Do we have to configure separate static ip, network name and physical disk
> for the MSDTC?
> Or we can use the same static ip, network name and physical disk(Q:quorum
> disk) that we configure for server clustering?
> Appreciate ur help.
> Tks
> --
> Message posted via http://www.droptable.com
>