extension .nc not registered in the factory

Mar 11, 2011 at 12:34 PM

When I install my application on another machine I try to read a NetCDF file I get an error that it cannot create a dataset from the uri because the extension .nc is not registered in the factory. DOes anyone know how I resolve this? The code works on my development machine and no references are missing as far as I can see.

 

 

Mar 11, 2011 at 1:44 PM

Available providers are taken from configuration files. SDS installer updates Machine.config, so any application that uses SDS library of installed version can use any of available providers. 

In your case there can be different reasons. 

  1. Is SDS installed on the machine? If not, you should either install the SDS library on that machine (recommended), or add a list of providers in the application config file and supply Microsoft.Research.Science.Data.NetCDF4 assembly and its dependencies with your application distribution.
  2. Is a version of SDS you are using equal to a version of installed SDS? If not, you should either use installed version or register providers of your version of library (see above). I would recommend you to use the published version of SDS unless you really need some extra capabilities that you want to add to the library and thus build your own version.

 

Please, tell me whether you succeeded with resolving the issue.

Dmitry.

Mar 11, 2011 at 2:51 PM

Thanks - installing the SDS library on the target computer has registered the dll and providers so everything now works

Mar 11, 2011 at 6:19 PM

For my understanding, is there any guidance as to how I should add the NetCDF4 provider (and others I may like to develop separately for other datatypes) in the application config? I would also need to ensure that the ucar/unidate Netcdf4.dll and Microsoft.Research.Science.Data.NetCDf4.dll files are included in my installation but shoudl I put these in teh GAC as is done with the SDS install?

Mar 11, 2011 at 7:09 PM

Hi. I've managed to resolve part of the problem by using the following code in my project

         Microsoft.Research.Science.Data.Factory.DataSetFactory.RegisterAssembly("Microsoft.Research.Science.Data.NetCDF4.dll")

However, if I try the same with the Memory provider this fails to work and I am unable to load this provider at run-time. I have tried:

        Microsoft.Research.Science.Data.Factory.DataSetFactory.RegisterAssembly("Microsoft.Research.Science.Data.Memory.dll")


Mar 23, 2011 at 1:54 PM
Edited Mar 23, 2011 at 1:55 PM

Hi,

if you have installed the SDS installation package, you may find a documentation file in Start / Programs / Scientific Data Set menu; in that documentation under Microsoft.Research.Science.Data.Factory namespace you can find remarks for the class DataSetFactory. There is a description of provider registration procedure.

The next sample demonstrates how to include a provider in the application config:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <!-- Declare configuration section named Microsoft.Research.Science.Data -->
  <configSections>
    <section name="Microsoft.Research.Science.Data.1.2" type="Microsoft.Research.Science.Data.Factory.FactoryConfigurationSection, Microsoft.Research.Science.Data, Version=1.2.6754.0, Culture=neutral, PublicKeyToken=e550de0161496f12" />
    <!-- Declarations of other config sections -->
  </configSections>
  <Microsoft.Research.Science.Data.1.2>
       <factories>
         <!-- Register factory by name -->
         <add name="nc" type="Microsoft.Research.Science.Data.NetCDF4.NetCDFDataSet, Microsoft.Research.Science.Data.NetCDF4, Version=1.2.6754.0, Culture=neutral, PublicKeyToken=e550de0161496f12"/>
         <add ext=".nc" type="Microsoft.Research.Science.Data.NetCDF4.NetCDFDataSet, Microsoft.Research.Science.Data.NetCDF4, Version=1.2.6754.0, Culture=neutral, PublicKeyToken=e550de0161496f12"/>       
</factories>
    </Microsoft.Research.Science.Data.1.2>
</configuration>

(Unfortunately, because of the bug, this approach doesn't work in Web Applications; if you need SDS in Web, please take a look here.)

You can either put the libraries in GAC or locate them in the execution directory of your application. But please note two moments:

1. NetCDF provider consists of 2 files: managed assembly Microsoft.Research.Science.Data.NetCDF4 and unmanaged NetCDF4.dll; they both must be presented side-by-side.

2.  There are separate versions of NetCDF: for x86 and x64 machines. On x64 machine, the SDS installer puts both versions into GAC (in fact, there are two GACs in on the x64 machine); and it is possible to fetch the files from GAC. In principle, you can dynamically register assembly that is located not in the execution directory using following syntax:

DataSetFactory.RegisterAssembly(
    Assembly.LoadFrom("/path/to/Microsoft.Research.Science.Data.NetCDF4.dll"));

and thus load different assemblies depending on a platform.

 

Regards,

Dmitry.