473,396 Members | 2,111 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

C# IIS MimeType Compiler Problem

Hi everybody,

I'm trying to add some mime types to the local IIS server using some c#
code.

The code I'm using is:

---snip---

DirectoryEntry _mimeMap =
new DirectoryEntry("IIS://localhost/MimeMap");

System.DirectoryServices.PropertyValueCollection _pcv =
_mimeMap.Properties["MimeMap"];

IISOle.MimeMapClass _mc =
new IISOle.MimeMapClass();

_mc.Extension = ".test";
_mc.MimeType = "application/octet-stream";

---/snip---

My Visual Studio Project has references to IISOle and ActiveDs. When
using Intellisense the object is there, I can browse the object browser,
everything shows up. I can see the MimeMap and MimeMapClass.

When I compile I keep getting:

[...]\IISController.cs(34,4): error CS0246: The type or namespace name
'IISOle' could not be found (are you missing a using directive or an
assembly reference?)

I really have no idea how IntelliSense can find the IISOle Namespace and
the Classes, but the compiler can't. Am I doing something obviously wrong?

I've seen the article:

http://msdn.microsoft.com/library/de...ryservices.asp

but I figured that if IntelliSense can find it, then it should be alright.

Is there any other way to add Mime Types to the IIS Metabase?

Thanks in advance,
Alex Duggleby
Jul 21 '05 #1
2 7043
Alex,

I have successfully used the following code to retrieve the Mime
Types:

using System;
using System.DirectoryServices;

using ActiveDs;

namespace MimeTypes
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class Class1
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{

// Look up the IIS Meta base for the mime mapping
DirectoryEntry mimeMap = new
DirectoryEntry("IIS://LocalHost/MimeMap");
System.DirectoryServices.PropertyValueCollection mimeMaps =
mimeMap.Properties["MimeMap"];
foreach (object map in mimeMaps)
{
IISOle.IISMimeType oleMap = map as IISOle.IISMimeType;
if (oleMap != null)
{
Console.WriteLine("{0} -> {1}", oleMap.Extension,
oleMap.MimeType);
}
}

mimeMap.Dispose();

}
}
}

I added the two references:

Active DS Type Library
Active DS IIS Namespace Provider

from the COM tab.
Jul 21 '05 #2
Alex,

I have successfully used the following code to retrieve the Mime
Types:

using System;
using System.DirectoryServices;

using ActiveDs;

namespace MimeTypes
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class Class1
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{

// Look up the IIS Meta base for the mime mapping
DirectoryEntry mimeMap = new
DirectoryEntry("IIS://LocalHost/MimeMap");
System.DirectoryServices.PropertyValueCollection mimeMaps =
mimeMap.Properties["MimeMap"];
foreach (object map in mimeMaps)
{
IISOle.IISMimeType oleMap = map as IISOle.IISMimeType;
if (oleMap != null)
{
Console.WriteLine("{0} -> {1}", oleMap.Extension,
oleMap.MimeType);
}
}

mimeMap.Dispose();

}
}
}

I added the two references:

Active DS Type Library
Active DS IIS Namespace Provider

from the COM tab.
Jul 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Alex Duggleby | last post by:
Hi everybody, I'm trying to add some mime types to the local IIS server using some c# code. The code I'm using is: ---snip--- DirectoryEntry _mimeMap =
7
by: Matthew | last post by:
Hi, I am using sun's CC (c++ compiler) to compile the follow code: #define __REENTRANT #include <stdio.h> #include <pthread.h> void *one(void *dummy);
5
by: Mark | last post by:
The following code works with gnu compilers (ISO compliant declaration of the variable "i") void foo() { for (int i = 0; i < length; i++) { loop code.... } for (int i = 0; i < length; ...
1
by: Sacha Faust | last post by:
I have an abstract class, RuleResponse, and then create a new class base on it, RuleResponseSequence, and override the ++ operater. If I try to cast a RuleResponse as a RuleResponseSequence and...
4
by: sqlguy | last post by:
Why do we have to contact MS for a problem that has been with this compiler from at least the beta of VS 20005. I am so sick and tired of the 30 - 40 clicks it takes to dismiss VS when there is a...
13
by: murphman | last post by:
I recently decided to do the right thing & write accessor functions for my class member variables instead of having them public and introduced a rather nasty bug. The class below shows the error -...
0
by: Allen Maki | last post by:
My compiler is acting up. When I have building error, the left margin pointer will point to the wrong line. Sometimes, the deferent between the line that has the error and the line it pointed to...
17
by: mdh | last post by:
I am working on 5.11 ( once again). So, just stepping through code in the debugger, and get this...and cannot proceed. Have posted to the Xcode forum, but my guess is the real gurus are here in...
7
by: Ginu | last post by:
Hi guys, I'm trying to run the compiler for Microsoft Visual Studio 2005 but receive this error when I try to run a simulation: "comp_msvc: Unable to execute compiler (Win32 error code: 2)...
0
by: Alejandro Gaio | last post by:
Hello All, I have a problem that appeared with the NEW VERSION of the vb.net compiler (VS 2008). To resume things, I have a project (call it "DocumentAdministrator") with several forms, and two...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.