473,406 Members | 2,312 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,406 software developers and data experts.

Why I can not compile this interface?

//This is my interface
namespace MyGroupPolicyObject
{
[ComImport, Guid("EA502723-A23D-11d1-A7D3-0000F87571E3"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown )]
public interface IGroupPolicyObject
{
void GetDisplayName(
[MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszName,
int cchMaxLength);
}
}
//this is my other class

using MyGroupPolicyObject;

namespace DomainGroupPolicy
{
public string m_gpName;
public class CommandLineProcess : IGroupPolicyObject
{
MyGroupPolicyObject gpo = new MyGroupPolicyObject();
m_gpName = gpo.GetDisplayName(strname, sizeof(strname));
}
}
Sep 8 '06 #1
2 2372
"ttan" <tt**@discussions.microsoft.coma écrit dans le message de news:
26**********************************@microsoft.com...

| //This is my interface
| namespace MyGroupPolicyObject
| {
| [ComImport, Guid("EA502723-A23D-11d1-A7D3-0000F87571E3"),
| InterfaceType(ComInterfaceType.InterfaceIsIUnknown )]
| public interface IGroupPolicyObject
| {
| void GetDisplayName(
| [MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszName,
| int cchMaxLength);
| }
| }

The interface compiles fine, the rest is uncompilable code.

| //this is my other class
|
| using MyGroupPolicyObject;
|
| namespace DomainGroupPolicy
| {
| public string m_gpName;

this string is not a member of a class

| public class CommandLineProcess : IGroupPolicyObject
| {

The class does not implement the interface

| MyGroupPolicyObject gpo = new MyGroupPolicyObject();
| m_gpName = gpo.GetDisplayName(strname, sizeof(strname));

This code belones in a method, it cannot be declared without.

| }
| }

Joanna

--
Joanna Carter [TeamB]
Consultant Software Engineer
Sep 8 '06 #2

"Joanna Carter [TeamB]" <jo****@not.for.spamwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
"ttan" <tt**@discussions.microsoft.coma écrit dans le message de news:
26**********************************@microsoft.com...

| //This is my interface
| namespace MyGroupPolicyObject
| {
| [ComImport, Guid("EA502723-A23D-11d1-A7D3-0000F87571E3"),
| InterfaceType(ComInterfaceType.InterfaceIsIUnknown )]
| public interface IGroupPolicyObject
| {
| void GetDisplayName(
| [MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszName,
| int cchMaxLength);
| }
| }

The interface compiles fine, the rest is uncompilable code.

| //this is my other class
|
| using MyGroupPolicyObject;
|
| namespace DomainGroupPolicy
| {
| public string m_gpName;

this string is not a member of a class

| public class CommandLineProcess : IGroupPolicyObject
| {

The class does not implement the interface

| MyGroupPolicyObject gpo = new MyGroupPolicyObject();
and finally, MyGroupPolicyObject is a namespace, not a class, so you can't
use "new".
| m_gpName = gpo.GetDisplayName(strname, sizeof(strname));

This code belones in a method, it cannot be declared without.

| }
| }

Joanna

--
Joanna Carter [TeamB]
Consultant Software Engineer


Sep 8 '06 #3

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

Similar topics

1
by: banjo123 | last post by:
Dear java.help: I just started learning java and was trying to compile some java sourc from the Javascript World Submission webpage. I know I have loaded m JDK successfully since I can compile...
19
by: Christopher | last post by:
I am getting a parse error from g++ pointing at my catch line and can't figure out whats wrong with this code: #include "BigPosInt.h" #include <iostream> #include <new> #include <assert.h> ...
2
by: Neil Davidson | last post by:
We have a component without a user interface which we want to license at design time. If someone has a design-time license then they should be able to compile applications using the component,...
3
by: Ruben Campos | last post by:
Greetings. Some time ago, I had writing a CVector <T, N> class, which implements an algebraic vector of arbitrary both dimension and scalar type. First, I defined the interface for the generic...
3
by: Eric Newton | last post by:
I'm wondering if there's a compile time cast gaurantee if any? Given the following: //----- begin sample code public interface IRegion { string Text { get; } RectangleF Area { get; } }
3
by: Lex | last post by:
How can I compile two classes from the command line that reference each other? Class A referenced Class B and Class B references Class A. Regards
1
by: steve smith | last post by:
Hi I have just downloaded the Borland C# Builder and the Micorsoft ..Net framework SDK v1.1 from the borland webist, and i am trying to get a simple program to run, however I keep getting errors,...
5
by: news.microsoft.com | last post by:
Hello all, I have a fairly complex solution that I will need to deploy as both a dll and exe depending on the type of installation. Is there a way to automate the build process so that a...
5
by: Laurent Allardin | last post by:
Hi, Why this code compile??? We should not be able to Override the code by using the Overloads since the sub as exactly the same parameters.... Thank you. Laurent Allardin,MCSD,MCAD
4
by: tony | last post by:
Hello! My question is about calling this method CollectData below but I get a compile error that I shouldn't have because the type parameter is correct. The compile error is the following:...
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: 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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.