Here is the error when calling SdfLoadProcedure.Execute(siteConnection):
External component has thrown an exception.
at FdoFeatureAccessManager.GetConnectionManager()
at Autodesk.MapGuide.Studio.Fdo.FdoUtil.GetConnection(Char* providerPrefix)
at Autodesk.MapGuide.Studio.Fdo.FdoUtil.SdfHasSpatialContextsWithWKTs(String filePath)
at Autodesk.MapGuide.Studio.Load.SdfLoadProcedure.ProcessSourceFile(PackageWriter package, String filePath, SiteConnection connection)
at Autodesk.MapGuide.Studio.Load.LoadProcedure.Execute(String packageFilePath, SiteConnection connection)
at Autodesk.MapGuide.Studio.Load.LoadProcedure.Execute(SiteConnection connection)
Here's the code:
SiteConnection siteConnection;
SiteManager siteManager = SiteManager.GetInstance();
ConnectionStatus status;
siteConnection = siteManager.CreateConnection("http://localhost/mapguide2011", "Administrator", "admin", out status);
SdfLoadProcedure sdfLoadProcedure = new SdfLoadProcedure();
sdfLoadProcedure.SourceFiles.Add("C:\SDF\test.sdf");
sdfLoadProcedure.RootPath = Library://123456/Loads/;
sdfLoadProcedure.CoordinateSystem = "LOCAL_CS[\"Non-Earth (Meter)\",LOCAL_DATUM[\"Local Datum\",0],UNIT[\"Meter\", 1],AXIS[\"X\",EAST],AXIS[\"Y\",NORTH]]";
sdfLoadProcedure.GenerateSpatialDataSources = true;
sdfLoadProcedure.SpatialDataSourcesFolder = "Data";
sdfLoadProcedure.SpatialDataSourcesPath = "";
sdfLoadProcedure.GenerateLayers = true;
sdfLoadProcedure.LayersFolder = "Layers";
sdfLoadProcedure.LayersPath = "";
sdfLoadProcedure.Generalization = 100;
sdfLoadProcedure.SdfKeyTreatment = SdfKeyTreatment.AutogenerateAll;
sdfLoadProcedure.Execute(siteConnection);
...and exception mentioned above rises after Execute(siteConnection).
Environment:
MapGuide Enterprise 2011
MapGuide Studio 2011
Windows Web Server 2008 64 bit
IIS 7.5
The same code works fine with MapGuide Studio 2009 API & MGOS 2.0 on Windows Server Standard 2008 32 bit & IIS 7.0.
In both cases Path-environment variable includes value pointing Studio installation folder.
Am I missing references? The code builds ok. Is there a problem with 64-bit environment? Studio is installed as a 32-bit application (under Program Files (x86)). The Application pool used on IIS is set to enable 32-bit applications.
Thank you for your help!
- vilunki
Little update:
I tried the way number 2 from Studio API reference with new error message:
[BadImageFormatException: is not a valid Win32 application. (Exception from HRESULT: 0x800700C1)]
System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection) +0
System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection) +43
System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +127
System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +142
System.Reflection.Assembly.Load(String assemblyString) +28
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +46
[ConfigurationErrorsException: is not a valid Win32 application. (Exception from HRESULT: 0x800700C1)]
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +613
System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +203
System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +105
System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +178
System.Web.Compilation.WebDirectoryBatchCompiler..ctor(VirtualDirectory vdir) +163
System.Web.Compilation.BuildManager.BatchCompileWebDirectoryInternal(VirtualDirectory vdir, Boolean ignoreErrors) +53
System.Web.Compilation.BuildManager.BatchCompileWebDirectory(VirtualDirectory vdir, VirtualPath virtualDir, Boolean ignoreErrors) +175
System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath) +86
System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile) +261
System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile) +101
System.Web.Compilation.BuildManager.GetVPathBuildResult(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile) +83
System.Web.Compilation.BuildManager.GetVPathBuildResult(HttpContext context, VirtualPath virtualPath) +10
System.Web.UI.WebServiceParser.GetCompiledType(String inputFile, HttpContext context) +43
System.Web.Services.Protocols.WebServiceHandlerFactory.GetHandler(HttpContext context, String verb, String url, String filePath) +180
System.Web.Script.Services.ScriptHandlerFactory.GetHandler(HttpContext context, String requestType, String url, String pathTranslated) +47
System.Web.HttpApplication.MapHttpHandler(HttpContext context, String requestType, VirtualPath path, String pathTranslated, Boolean useAppConfig) +193
System.Web.MapHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +93
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155
Again, the same thing works fine with 32-bit environment (MapGuide Studio 2009 API & MGOS 2.0 on Windows Server Standard 2008 32 bit & IIS 7.0).
I forgot to mention in previous post, that the MapGuide Studio 2011 installation itself works also fine on 64-bit environment (installed in Program Files (x86)).
- vilunki