Calling VB DLL from Delphi - Access Violation Error In Delphi After DLL is rebuilt?



Hi,
I'm new to dealing with DLLs in delphi so you'll have to excuse me if this
is a silly question, but I can't find anything in either the help or on
google groups search.

I have a DLL created in VB called "helloworld", with just one class
"class1". It contains just one function, "temp":
Public Function tempfunc() As String
tempfunc = "Hello from function temp"
End Function

- which works fine.

Now I want to use it in Delphi. I have created a new project (standard EXE)
and on the form added an edit box and a button. I have then clicked project
and import type library, and imported my dll generating the wrapper classes.

I have then added "helloworld_tlb" to the uses section; and added the follow
code to the button1click method/event:-

procedure TForm1.Button1Click(Sender: TObject);
var test: helloworld.class1 ;
begin
test:=helloworld.Coclass1.Create;
edit1.Text:=test.tempfunc();
end;

Now this all works fine, when I run the form and click the button it puts
"hello from function temp" in the edit box.

However.......

As/when the VB DLL is recompiled (which, when I come to using this for
something more practical, may be the case), when I next come to run the
delphi form, I get an exception EIntfCastError with message 'Interface not
supported'. The only solution to get this working again is to re-import the
type library into the project - but, once deployed, the DLL (in this case
from another application) may be updated and I don't really want to have to
make sure my delphi program is updated every time (working on the assumption
that just because the DLL is updated, existing functionality is not changed,
only new stuff added).

Any thoughts on how I get round this? Presumably it's something to do with
the DLL version?

Thanks
Andrew


.


Quantcast