"ESRI.ArcGIS.DataSourcesGDB.FileGDBWorkspaceFactoryClass" cannot be embedded
Asked Answered
P

2

6

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?

Petropavlovsk answered 27/11, 2013 at 10:10 Comment(2)
Try to replace FileGDBWorkspaceFactoryClass with FileGDBWorkspaceFactory. I guess there were such questions, #2484159, #4220105Monika
@johny this fixed it for me. If you could provide this as an answer, I would love to accept it.Petropavlovsk
M
0

You may try to remove Class suffix. Replace

IWorkspaceFactory workspaceFactory = new FileGDBWorkspaceFactoryClass();

with

IWorkspaceFactory workspaceFactory = new FileGDBWorkspaceFactory();

Here https://mcmap.net/q/27193/-it-looks-like-i-39-m-instantiating-this-speechapi-interface-how-is-that-possible Michael Petrotta's answer explains why.

Here are similar answers: Interop type cannot be embedded, Class cannot be embedded. Use the applicable interface instead.

Monika answered 6/1, 2014 at 15:46 Comment(0)
A
2

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.

Albescent answered 12/12, 2013 at 13:1 Comment(0)
M
0

You may try to remove Class suffix. Replace

IWorkspaceFactory workspaceFactory = new FileGDBWorkspaceFactoryClass();

with

IWorkspaceFactory workspaceFactory = new FileGDBWorkspaceFactory();

Here https://mcmap.net/q/27193/-it-looks-like-i-39-m-instantiating-this-speechapi-interface-how-is-that-possible Michael Petrotta's answer explains why.

Here are similar answers: Interop type cannot be embedded, Class cannot be embedded. Use the applicable interface instead.

Monika answered 6/1, 2014 at 15:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.