我的com+,为什么总是提示“灾难性错误”???(50分)

  • 主题发起人 主题发起人 futureyre
  • 开始时间 开始时间
F

futureyre

Unregistered / Unconfirmed
GUEST, unregistred user!
我用dephi写的com+组件,后台数据库是sqlserver2000,
现在客户端调用接口方法,总是提示“灾难性错误”,为什么啊???
比如用户登录:
procedure TForm4.Button1Click(Sender: TObject);
var
LoginObj : ImtsLogin;
vCookie : OleVariant;
begin
LoginObj := ComtsLogin.CreateRemote('ZWL');
LoginObj.Login(Edit1.Text,Edit2.Text,vCookie);//执行到这一步提示“灾难性错误”!!!
if (vCookie<>'') then
begin
Form1.ShowModal;
end
else
ShowMessage('错误的用户名或密码');
end;
 
LoginObj.Login(Edit1.Text,Edit2.Text,VarToStr(vCookie))
试试
 
这要看你的COM里是如何写的吧??
 
unit UnitLogin;
{$WARN SYMBOL_PLATFORM OFF}
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ComServ, ComObj, VCLCom, StdVcl, bdemts, DataBkr, DBClient,
MtsRdm, Mtx, ProjectLogin_TLB, Contnrs;
type
TSimpleProfile = class(TObject)
private
fName : string;
fPassword : string;
fCookie : string;
published
property Name : string read fName write fName;
property Password : string read fPassword write fPassword;
property Cookie : string read fCookie write fCookie;
end;

Tmtslogin = class(TMtsDataModule, Imtslogin)
private
{ Private declarations }
aProfile : TObjectList;
procedure SetupProfile;
protected
class procedure UpdateRegistry(Register: Boolean;
const ClassID, ProgID: string);
override;
procedure Login(const sName, sPassword: WideString;
var vCookie: OleVariant);
safecall;
public
{ Public declarations }
procedure Initialize;
destructor Destroy;
override;
end;

var
mtslogin: Tmtslogin;
implementation
{$R *.DFM}
class procedure Tmtslogin.UpdateRegistry(Register: Boolean;
const ClassID, ProgID: string);
begin
if Register then
begin
inherited UpdateRegistry(Register, ClassID, ProgID);
EnableSocketTransport(ClassID);
EnableWebTransport(ClassID);
end else
begin
DisableSocketTransport(ClassID);
DisableWebTransport(ClassID);
inherited UpdateRegistry(Register, ClassID, ProgID);
end;
end;

procedure TmtsLogin.Initialize;
begin
inherited;
aProfile := TObjectList.Create;
SetupProfile;
end;

Destructor TmtsLogin.Destroy;
begin
inherited;
aProfile.Clear;
aProfile.Free;
end;

procedure TmtsLogin.SetupProfile;
var
aPerson : TSimpleProfile;
begin
aPerson := TSimpleProfile.Create;
aPerson.Name := 'db';
aPerson.Password := 'db';
aPerson.Cookie := CreateClassID;
aProfile.Add(aPerson);
end;

procedure Tmtslogin.Login(const sName, sPassword: WideString;
var vCookie: OleVariant);//这里是Login方法!!!
var
iCount : Integer;
aPerson : TSimpleProfile;
begin
vCookie := '';
for iCount := 0 to aProfile.Count-1do
begin
aPerson := TSimpleProfile(aProfile.Items[iCount]);
if ( (aPerson.Name = sName) and (aPerson.Password = sPassword) ) then
vCookie := aPerson.Cookie;
end;
end;

initialization
TComponentFactory.Create(ComServer, Tmtslogin,
Class_mtslogin, ciMultiInstance, tmApartment);
end.
 
是提示“灾难性故障”,不知道哪里出了问题??
各位大富翁,如果解决了问题,我可以再加分把分数都给你啊!!帮帮忙吧!!
 
问题解决了!!
 
请问你的问题如何解决的?我也遇到这个问题!开始还是正常的,不知道现在改了什么?就提示“灾难性错误”!!谢谢!
 
请问你的问题如何解决的?我也遇到这个问题!开始还是正常的,不知道现在改了什么?就提示“灾难性错误”!!谢谢!
不过我是在insert数据库时出错的!
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
I
回复
0
查看
583
import
I
I
回复
0
查看
948
import
I
后退
顶部