"ESRI.ArcGIS.DataSourcesGDB.FileGDBWorkspaceFactoryClass" cannot be embedded

I made an application to add arcmap in C #, and I tried to connect to my geodatabase. So when I tried to run it, I got this error:

Error 1 Interop type 'ESRI.ArcGIS.DataSourcesGDB.FileGDBWorkspaceFactoryClass' cannot be embedded. Use the applicable interface instead. 

and then the add path in

I had never seen this error before, and I was wondering what was going wrong.

This is the main code:

  public IWorkspace FileGdbWorkspaceFromPropertySet(string database) { IPropertySet propertySet = new PropertySetClass(); propertySet.SetProperty("DATABASE", database); IWorkspaceFactory workspaceFactory = new FileGDBWorkspaceFactoryClass(); return workspaceFactory.Open(propertySet, 0); } 

So the error in this line is:

 IWorkspaceFactory workspaceFactory = new FileGDBWorkspaceFactoryClass(); 

I hope someone can give me an explanation of this error, as well as a possible fix in my case.

What is going wrong?

+6
source share
2 answers

You may try to remove the Class suffix. Replace

Workspace IWorkspaceFactoryFactory = new FileGDBWorkspaceFactoryClass ();

with

Workspace IWorkspaceFactoryFactory = new FileGDBWorkspaceFactory ();

Here fooobar.com/questions/7294 / ... Michael Petrotta explains why.

Here are similar answers: Integration type cannot be implemented , Class cannot be embedded. Use the appropriate interface instead .

0
source

It looks like the ESRI dll has been built into your assembly. Assuming you are working with Visual Studio - Select the reference DLL, and in its properties set "Insert Interaction Types" to "False."

Note that this will create an interaction file for this DLL, which you will need to place next to your assembly.

+2
source

Source: https://habr.com/ru/post/958913/


All Articles