Re: Trying to create a dll accessible from SQL Server (sp_OACreate), here is my code..



Hi,

you have to declare your types as [ComVisible(true)].

However, you should have a look at
  http://support.microsoft.com/kb/q238425/
first - wininet does not support being used from within a service.

Do you really want your SQL server to use FTP?

/Johannes

Todd S wrote:
I am trying to create a class library accessible to in SQL server as a
COM. I am using the Wininet.dll and can get it to build successfully. I
then run tlbexp and create the type library and when I attempt to
register the dll with regasm.exe I get the following error:

RegAsm : warning RA0000 : No types were registered


This is my code:

using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using System.Reflection;
using System.IO;


namespace BDS_FTP { public class FTP { public FTP() { //COM requires an empty constructor }

        //DECLARATIONS

		[DllImport("wininet.dll")]
		public static extern long InternetOpen( string strAppName,
                                                long ulAccessType,
                                                string strProxy,
                                                string strProxyBypass,
                                                long ulFlags);

		[DllImport("wininet.dll")]
		public static extern long InternetConnect(long ulSession,
                                                    string strServer,
                                                    int ulPort,
                                                    string strUser,
                                                    string strPassword,

                                                    long ulService,
                                                    long ulFlags,
                                                    long ulContext);

       [DllImport("wininet.dll")]
        public static extern bool InternetGetConnectedState(ref uint
ulFlags, uint ulReserved);


[DllImport("wininet.dll")] public static extern bool FtpSetCurrentDirectory(IntPtr ulSession, string strPath);


[DllImport("wininet.dll")] public static extern bool FtpGetFile(IntPtr ulSession, string strRemoteFile, string strLocalFile, bool bolFailIfExist, ulong ulFlags, ulong ulInetFals, ulong ulContext);


}
}


Any advice or help would be greatly appreiciated!
Thanks!
Todd S

.



Relevant Pages

  • Verify a Windows Account
    ... static bool authUserLocal(string username, string password) ... public static extern bool LogonUser(string lpszUsername, ... int dwLogonType, int dwLogonProvider, out int phToken); ...
    (microsoft.public.dotnet.framework)
  • Verify a Windows Account
    ... static bool authUserLocal(string username, string password) ... public static extern bool LogonUser(string lpszUsername, ... int dwLogonType, int dwLogonProvider, out int phToken); ...
    (microsoft.public.dotnet.general)
  • S4U Kerberos for calling WCF services
    ... I want use S4U Kerberos for calling WCF services using delegate account. ... String lpszPassword,int dwLogonType, int dwLogonProvider, out System.IntPtr ... public static extern int GetLastError; ... using (AgenteTareas agenteTareas = new AgenteTareas()) ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • Re: PInvoke Marshalling....
    ... The wParam is a pointer to a API defined structure (containing a Low DWORD ... contents of the string builder. ... "DeviceHandle" and not indicative that it is a windows handle. ... public static extern int SNAPI_SetVersionBuffer(IntPtr DeviceHandle, ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Unable to properly set the InteractiveProcess property on a windows service
    ... public static extern IntPtr ... IntPtr OpenSCManager(string lpMachineName, string ... OpenService(IntPtr hSCManager, string lpServiceName, ... installer code looks like this... ...
    (microsoft.public.dotnet.languages.csharp)