Okay, I know this isn't a solution but there's no good place to put this. I don't want to put it in the O.P. as an "improvement" because it might not get noticed. And if I post it as a comment it doesn't let me create code tags. So it's here.
Earlier I said I was going to handle this with a console application. Although that works, it's not really the way I want to go. I can't return anything of value from a console application and calling it is not elegant at all. I really need this to be a dll.
So I created an even simpler one. I didn't register it. I can use it in another vb.net forms application just fine because it's easy to create a reference to it.
Here's my dll code (there are no special references, just the default ones for a .net dll):
Public Class Class1
Public Shared Function returnJunk(inputParam As Int16)
Select Case inputParam
Case 1
Return "one"
Case 2
Return "two"
Case 3
Return "three"
Case 4
Return "four"
Case 5
Return "five"
Case Else
Return "nothing"
End Select
End Function
End Class
Here's my call to it from vb.net
Private Sub SimpleButton2_Click(sender As Object, e As EventArgs) Handles SimpleButton2.Click
MessageBox.Show(TestDLLJunk.Class1.returnJunk(14))
End Sub
In the calling application, I just right clicked references and browsed to where the compiled dll is. It shows the full path to it in the properties of the dll's reference.
So then I did the same as before in Delphi. This is in my interface uses:
Function returnJunk(inputParam: Byte): string; STDCALL; EXTERNAL 'TestJunk.dll';
Compiling my dll code creates 3 files. I put them ALL in the source folder of my Delphi project and also in the Win32\debug folder just for grins.
And this is my calling code:
procedure TForm1.Button2Click(Sender: TObject);
var
rj: string;
begin
rj := returnJunk(4);
end;
Same as before. It compiles but doesn't run. I get the same message as in my O.P.
Then, for the heck of it, I registered it:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\RegAsm.exe D:\Data\1Work\KT\DelphiTokyoVersion\TokyoConversionTestProjects\TestDLLJunk\bin\Release\TestDLLJunk.dll /tlb /codebase
Same results as before.