C# Union in B4PPC

tsdt

Active Member
Licensed User
Hi,

I was trying to create a union in C#, however, in b4ppc, it prompts me an error saying that it cannot load the library. I notice that Agraham created that before but using unsafe mode. Is it true that B4PPC can only compile using unsafe mode?

Please advice.

Thanks
 

tsdt

Active Member
Licensed User
There is no need to compile using unsafe mode unless the C# code requires it.

Hi Erel,

Thanks for the reply. Sorry for the confusion, actually, I dont mean compiling it. I meant loading it to B4PPC.

I was doing the normal structure using Layout.Explicit in C#, but, I didnt declare unsafe in the C#. I managed to compile it in C#. Use the dll file in b4PPC. When I call the dll, it prompt me error saying that cannot load the library. I checked in the b4PPC forum and noticed that Agraham was doing the same thing as well, but, using unsafe mode. I believe he managed to create the dll and use that in his code.

Hence, my question is that do I really need to do an unsafe mode in my code to be able to load the dll in b4PPC. Seems like b4PPC rejected that coding.

Please advise.

Thanks
 

tsdt

Active Member
Licensed User
Hi Erel,

Thanks for the reply. Sorry for the confusion, actually, I dont mean compiling it. I meant loading it to B4PPC.

I was doing the normal structure using Layout.Explicit in C#, but, I didnt declare unsafe in the C#. I managed to compile it in C#. Use the dll file in b4PPC. When I call the dll, it prompt me error saying that cannot load the library. I checked in the b4PPC forum and noticed that Agraham was doing the same thing as well, but, using unsafe mode. I believe he managed to create the dll and use that in his code.

Hence, my question is that do I really need to do an unsafe mode in my code to be able to load the dll in b4PPC. Seems like b4PPC rejected that coding.

Please advise.

Thanks

ps. I didnt convert my code to unsafe mode to try. :(
 

tsdt

Active Member
Licensed User
If the C# code requires to be compiled with unsafe flag then you need to add a comment at the beginning of the file that will tell Basic4ppc to compile it with /unsafe flag.

Hi Erel,

Thanks again for the reply. I think you might have misunderstood my question. I am referring why if I use the "safe" mode, b4ppc fail to load, whereas if I use the "unsafe" mode, b4ppc managed to load.

That's my question. As for the unsafe flag, actually, I did not use the b4ppc to compile my C# code (sorry for the confusion before), I only load the dll for my b4ppc program to instantiate the dll object in b4ppc. (not sure you can understand this).

Thanks again and hope u can understand what my question is. ;)
 

agraham

Expert
Licensed User
Longtime User
Several of my libraries need unsafe mode to compile and I've never come across a problem like that. If you can post a small dll, preferably also with the source code, that displays the problem I'll poke around to see if I can work out why it won't load.
 

mrjaw

Active Member
Licensed User
Longtime User
There is a place where I can find an example about create a DLL using C# and load this from B4PPC
?
 
Top