Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Interop / April 2004

Tip: Looking for answers? Try searching our database.

Modifying EntryPoint in DllImportAttribute at runtime

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Raja - 12 Apr 2004 16:16 GMT
I have a C dll that has several functions with following following signature

void func_Struct1(Struct1* ptr
void func_Struct2(Struct2* ptr
.....................................
......................................
void func_Structn(Structn* ptr

I want to P/Invoke these functions. First I started writing one P/Invoke equivalent for each of these C-Functions.
Now I think if I could write just one func of kind

[DllImport("xyz.dll",EntryPoint="SomeInitValue")
void func_struct(MarshalAs(UnmanagedType.AsAny) object ptr)

And if I could later on modify the entrypoint at runtime, I could achieve it. So I want to know how I could modify EntryPoint to, for example func_struct2, at runtime. This way C#-client will call func_struct() but actually a func_struct2() will be called
Mattias Sj?gren - 17 Apr 2004 16:47 GMT
>And if I could later on modify the entrypoint at runtime, I could achieve it. So I want to know how I could modify EntryPoint to, for example func_struct2, at runtime.

No, you can't modify compiled code at runtime.

You can, however, generate new code. See

http://www.msjogren.net/dotnet/eng/samples/dotnet_dynpinvoke.asp

for an example.

However, if I were you I'd still go with static compile time checked
declarations. Why don't you want that?

Mattias

Signature

Mattias Sjögren [MVP]  mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.


Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.