|
Hi all. I am a newbie to writing API's. Should I start with ASP.NET Core or ASP.NET Framework? Can I use them for backend development too?
|
|
|
|
|
|
Hi,
I'm trying to create a simple COM component in .NET 5. I have gotten this far:
- I have created an interface with the right attributes:
[ComVisible(true)]
[Guid("12345678-3e60-4c56-abcd-13d4098434f7")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IConvertor
{
string ConvertPatient(string s);
} - I have created a class that implements this interface:
[ComVisible(true)]
public class Convertor : IConvertor
{
public Convertor()
{ }
public string ConvertPatient(string s)
{
return "Hello, " + s;
}
}
I tried with and without the ClassInterface and Guid attributes.
I compiled for x86 and I got these files (and some more):
xxx.comhost.dll
xxx.dll
The problem is that I don't manage to register this component.
tlbexp xxx.InterOp.dll gives me this error:
Quote: TlbExp : error TX0000 : Type library exporter encountered an error while processing 'hdmpcloud.ehealth.FhirTools.InterOp.Convertor, hdmpcloud.ehealth.FhirTools.InterOp'. Error: Type library exporter cannot load type 'hdmpcloud.ehealth.FhirTools.InterOp.Convertor' (error: Could not load file or assembly 'System.Runtime, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. (Exception from HRESULT: 0x80070002)).
regasm /tlb xxx.InterOp.comhost.dll gives me
Quote: RegAsm : error RA0000 : Failed to load 'C:_projects\HDMP\hdmpcloud.ehealth.FhirTools\InterOp\hdmpcloud.ehealth.FhirTools.InterOp\bin\Debug\net5.0\hdmpcloud.ehealth.FhirTools.InterOp.comhost.dll' because it is not a valid .NET assembly
I want to call this component from a Delphi program (unmanaged code).
The documentation ( Interoperating with unmanaged code - .NET Framework | Microsoft Docs ) is not very clear on a couple of things:
- Is COM still possible in .NET 5?
- The documentation is for .NET in general, but they don't specify a version.
Any help or pointers in the right direction would be much appreciated. And before you ask... yes, this will become an article
Gaston
|
|
|
|
|
The file you're trying to register seems to have no relation to "Convertor"; at least as far as naming goes. And I would have picked a more unique name than "Convertor".
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it.
― Confucian Analects: Rules of Confucius about his food
|
|
|
|
|
Hi Gerry,
Thanks for the tips. But I'm afraid that changing the names will not help in registering the COM component. If you have tips for that I'll be glad to hear them.
Thanks,
Gaston
|
|
|
|
|
|
Thanks for the link!
Unfortunately it doesn't help. It seems that regasm doesn't recognize .NET 5 assemblies. Regsvr32 does, and it registers the component / interface / library, but no TLB is generated. That makes it virtually useless.
From Exposing .NET Core components to COM | Microsoft Docs :
Quote: Unlike in .NET Framework, there is no support in .NET Core or .NET 5+ for generating a COM Type Library (TLB) from a .NET assembly. The guidance is to either manually write an IDL file or a C/C++ header for the native declarations of the COM interfaces.
So now I'm investigating how to create / compile / use the correct IDL file. Should anyone have some good pointers for that, let me know
Thanks,
Gaston
|
|
|
|
|
|
Hi Gerry,
I was under the assumption that creating a COM component would still be as easy under .NET 5 as under the previous versions. We don't need real time at all.
This would be part of a conversion program, that will run on the client PCs (> 3000 clients, with all sorts of PCs and OS's). I wanted to avoid having to serialize objects on the Delphi side, and to deserialize them on the .NET side. I think that we will resort to creating a file (or a couple of files) in a folder, and when that is done running the conversion program on the client PC. That way we only have to install .NET 5 and the conversion program, which is even easier than using a queue.
Thank you for thinking with me for solutions!
I am going to do 1 more try, posting the same question on SO. Please don't be insulted If I find a solution I will post it here.
|
|
|
|
|
Seems it's more of a "command and control" issue than a data transfer one. Lots of possible scenarios.
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it.
― Confucian Analects: Rules of Confucius about his food
|
|
|
|
|
Indeed, we have thought of alternatives before going to the "COM road". But COM seemed the easiest in our case for a couple of reasons, hence the initial question here.
|
|
|
|
|
According to the replies on SO this is a dead end indeed.
We now are going to create classes in C# and in Delphi with all the same properties. We'll then serialize the Delphi classes to JSON, and deserialize them in C#.
For this I'm writing a code generator that will use a DSL to describe the classes. It's a work-around, but at least we'll get the work done.
|
|
|
|
|
That's the protocol; you still need a transport mechanism.
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it.
― Confucian Analects: Rules of Confucius about his food
|
|
|
|
|
This is for a conversion, so the Delphi side will serialize the objects in a folder, and the .NET part will deserialize it and handle it further.
It is a One Shot operation, so no need for fancy stuff there.
|
|
|
|
|
Hi All, I hope now this is the correct forum for suggestions. This Type bottoms need to be bigger and more precise so people did not get flagged for asking a suggestion that i found unnecessary for been flagged, If someone here knows any type of free code camp please share the resource I immensely trying to enhanced my knowledge and I know someone of you there knows some free learning resources.
Thank you
|
|
|
|
|
You forgot to explain what it is you want to learn about.
|
|
|
|
|
Based on the subject, I'm tempted to post a link to this Wikipedia article[^].
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
go head you discover america
|
|
|
|
|
a lot ppl here think are poets.. pls gime a break.
|
|
|
|
|
Not a Rick Roll[^]
Bastard Programmer from Hell
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
I can see it,
|
|
|
|
|
I was honest, not a Rick Roll. A for learning resources; Manning has some good books.
If you wanna learn fast and hard, try writing an article for this site
Bastard Programmer from Hell
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
This site its not all that. There are some people very intelligent who dont waste time and go to the point, not sure how they do but they manage to email me directly I like it with tons of creative stuff and very helpful. I suggest you to learn from them more maybe you can enhance your brain. They can give you more tips, Good luck
|
|
|
|
|
lv11 wrote: I suggest you to learn from them more maybe you can enhance your brain Hahaha
I threw a professor out of the class, took over and started teaching
You were saying?
Bastard Programmer from Hell
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
what movie was that? i think you your brain its toasted get help
|
|
|
|