开发者

IISOle.MimeMapClass has no constructors

I trying to use the MimeMapClass from IISOle.

I am getting the following error

The type 'IISOle.MimeMapClass' has no constructors de开发者_如何转开发fined  

It happens when I try to instantiate the object

vRoot.Properties["MimeMap"].Add(new MimeMapClass { Extension = ext, MimeType = mime });

I get additional errors:

Interop type 'IISOle.MimeMapClass' cannot be embedded. Use the applicable interface instead.

'IISOle.MimeMapClass' does not contain a definition for 'Extension'

I have no idea why this is happening.

Any ideas?


I am not sure if this is your issue as I don't know if you are using VS2010 or not. But if you are, try not embedding the interop types (see the properties of the reference you have added). According to this article it can cause you these type of troubles


Have you tried the following? (Not production code - No error handling, disposing, or check for existing items provided.)

DirectoryEntry mimeMap = new DirectoryEntry("IIS://localhost/MimeMap")

PropertyValueCollection collection = mimeMap.Properties["MimeMap"];

MimeMapClass newMimeType = new MimeMapClass();
newMimeType.Extension = ext;
newMimeType.MimeType = mime;
collection.Add(newMimeType);
mimeMap.CommitChanges();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜