Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I made an add in application for arcmap in C# and I tried to connect with my File 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 path of the add in

I have never seen this error before and I was wondering what is going wrong.

This is the main code it's all about:

 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 is at this line:

IWorkspaceFactory workspaceFactory = new FileGDBWorkspaceFactoryClass();

I hope someone can provide me an explanation of this error and also a possible fix in my case.

What is going wrong?

like image 245
Loko Avatar asked Nov 27 '13 10:11

Loko


1 Answers

Looks like the ESRI dll was embedded in your assemly. Assuming you are working with Visual Studio - Select the referenced dll, and in its properties set "Embed Interop Types" to False.

Note that this will create an interop file for that DLL which you will need to put next to your assembly.

like image 146
aturns Avatar answered Oct 15 '22 16:10

aturns