Custom .NET Data Providers

后端 未结 1 1792
说谎
说谎 2021-02-09 01:23

Is is possible to use a custom .NET data provider without installing it in the GAC?

Can I reference a custom DLL and register it inside my configuration file?

1条回答
  •  悲&欢浪女
    2021-02-09 02:04

    Yes, you can register an implementation of the DbProviderFactory class by adding the following section in your configuration file:

    
        
            
        
    
    

    The MyCustomDataProvider assembly doesn't have to be registered in the GAC but can be deployed together with the application as a private assembly.

    You can refer to the registered data provider programmatically by using the value specified in the invariant attribute. For example you could tell ADO.NET to use the MyNamespace.MyCustomProviderFactory by specifying MyCustomProvider as the providerName in the connection string:

    
        
    
    

    In code you can use the same provider name with the DbProviderFactories.GetFactory method:

    DbProviderFactory factory = DbProviderFactories.GetFactory("MyCustomDataProvider");
    

    where factory will be an instance of the MyNamespace.MyCustomProviderFactory class.

    0 讨论(0)
提交回复
热议问题