Click here to Skip to main content
11,920,211 members (51,151 online)
Click here to Skip to main content


87 bookmarked

How to Automate Exporting .NET Function to Unmanaged Programs

, 21 Nov 2006 CPOL
Post-build tool which can automate exporting .NET function to unmanaged programs
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;

namespace ExportDllAttribute
    public class ExportDllAttribute: Attribute
        public ExportDllAttribute(string exportName)
            : this(exportName, System.Runtime.InteropServices.CallingConvention.StdCall)

        static Dictionary<System.Runtime.InteropServices.CallingConvention, string> dic = new Dictionary<CallingConvention,string>();

        static ExportDllAttribute()
            dic[System.Runtime.InteropServices.CallingConvention.Cdecl] = typeof(CallConvStdcall).FullName;
            dic[System.Runtime.InteropServices.CallingConvention.FastCall] = typeof(CallConvFastcall).FullName;
            dic[System.Runtime.InteropServices.CallingConvention.StdCall] = typeof(CallConvStdcall).FullName;
            dic[System.Runtime.InteropServices.CallingConvention.ThisCall] = typeof(CallConvThiscall).FullName;
            dic[System.Runtime.InteropServices.CallingConvention.Winapi] = typeof(CallConvStdcall).FullName;

        public ExportDllAttribute(string exportName, System.Runtime.InteropServices.CallingConvention CallingConvention)
            m_ExportName = exportName;
            m_CallingConvention = dic[CallingConvention];

        private string m_ExportName;
        public string ExportName
            get { return m_ExportName; }

        private string m_CallingConvention;
        public string CallingConvention
            get { return m_CallingConvention; }

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Systems / Hardware Administrator
Poland Poland
No Biography provided

You may also be interested in...

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.151120.1 | Last Updated 22 Nov 2006
Article Copyright 2006 by Selvin
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid