473,385 Members | 1,344 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,385 software developers and data experts.

Is this possible? Equivalent of C++ header file?

OK, lets say I have a C# Windows application. In it is a a series of
namespaces, all rooted for a certain namespace A.

For ex, the "using" directives would read something like:
using A;
using A.somenamespace;
using A.anothernamespace;

Now, other users will be using these namespaces. I would like for them to
be able to take advantage of the intellisense features in Visual Studio, but
I do not want to actually give them the source code (or give them a DLL with
the necessary files). In other words, I want them to be able to code using
it, but not actually be able to run it (does that make sense? I know it
seems a little wierd). In C++, this would simply be done by creating a
header file. Unfortunately, I'm not familiar enough with C# to know how to
go about doing something similar.

So, is there anyway that this can be done?

--
Adam Clauss
ca*****@tamu.edu
Nov 15 '05 #1
4 2818
Adam Clauss wrote:
OK, lets say I have a C# Windows application. In it is a a series of
namespaces, all rooted for a certain namespace A.

For ex, the "using" directives would read something like:
using A;
using A.somenamespace;
using A.anothernamespace;

Now, other users will be using these namespaces. I would like for them to
be able to take advantage of the intellisense features in Visual Studio, but
I do not want to actually give them the source code (or give them a DLL with
the necessary files). In other words, I want them to be able to code using
it, but not actually be able to run it (does that make sense? I know it
seems a little wierd). In C++, this would simply be done by creating a
header file. Unfortunately, I'm not familiar enough with C# to know how to
go about doing something similar.

So, is there anyway that this can be done?


In C#, the assembly is used to get the information that C/C++ compilers
used header files for. So to get intellisense, the coders need an
assembly of some sort.

Probably the cleanest way to do what you appear to want to do is to have
all of the methods you want them to code against be interfaces. That
way, you can compile an assembly that has nothing but the interface
declarations - no implementation code would be in that assembly.

They can reference that assembly for intellisense.

Your code with the classes that implement the interfaces would reference
the same assembly.

One drawback to this is that interfaces cannot contain static methods.
This might also require a big change in the design of whatever you're doing.

Another option might be to use #if/#endif conditional compilation to
build version of your assemblies that have no real implementation. They
can code against those assemblies, then submit the code to whomever to
build against assemblies that have real implementations. I'm not sure
how well this would really work.

--
mikeb
Nov 15 '05 #2
Hmm I was afraid it might not be easy ;)

I'll look into those methods, see if either is doable.

I agree that the first method would be the 'best' to implement,
unfortunately it may be too late to go through and change that at this
point.

What I'm trying to accomplish here:
The app in question (not open source) compiles various scripts at runtime.
For users designing these runtime scripts, I would like for them to have
available all the classes, methods, etc in intellisense for them to use -
Right now they just have to memorize everything.

They cannot and do not need to actually BUILD against my assembly - the
program does that itself at runtime.

--
Adam Clauss
ca*****@tamu.edu
"mikeb" <ma************@mailnull.com> wrote in message
news:uZ**************@TK2MSFTNGP11.phx.gbl...
Adam Clauss wrote:
OK, lets say I have a C# Windows application. In it is a a series of
namespaces, all rooted for a certain namespace A.

For ex, the "using" directives would read something like:
using A;
using A.somenamespace;
using A.anothernamespace;

Now, other users will be using these namespaces. I would like for them to be able to take advantage of the intellisense features in Visual Studio, but I do not want to actually give them the source code (or give them a DLL with the necessary files). In other words, I want them to be able to code using it, but not actually be able to run it (does that make sense? I know it
seems a little wierd). In C++, this would simply be done by creating a
header file. Unfortunately, I'm not familiar enough with C# to know how to go about doing something similar.

So, is there anyway that this can be done?

In C#, the assembly is used to get the information that C/C++ compilers
used header files for. So to get intellisense, the coders need an
assembly of some sort.

Probably the cleanest way to do what you appear to want to do is to have
all of the methods you want them to code against be interfaces. That
way, you can compile an assembly that has nothing but the interface
declarations - no implementation code would be in that assembly.

They can reference that assembly for intellisense.

Your code with the classes that implement the interfaces would reference
the same assembly.

One drawback to this is that interfaces cannot contain static methods.
This might also require a big change in the design of whatever you're

doing.
Another option might be to use #if/#endif conditional compilation to
build version of your assemblies that have no real implementation. They
can code against those assemblies, then submit the code to whomever to
build against assemblies that have real implementations. I'm not sure
how well this would really work.

--
mikeb

Nov 15 '05 #3
Adam,

It is not difficult to create an interface. It is very much like a header.
You create a new project, create the interface objects (like class
definitions, but containing no method code), and compile it. You distribute
the resulting DLL.

To be certain that you are meeting the same interface expectations, you
should derive your objects from the same definitions.
Depending on the number of classes, this can take a little while, but not a
terribly long period of time. You should be able to create an interface for
each exposed class at a rate of one per 10-15 minutes. If you expose 80
classes, you can do this in a few days... (Really... count your classes...)
If you were prepared to create header files, you can create interfaces.

For the interfaces that require static methods, simply create a "shell"
class (perhaps using the #ifdef idea that mikeb suggests) and include it in
an alternate assembly (for ease of deployment).

One advantage to interface objects for the future: your users CAN compile
the code themselves... and you can call the code with confidence knowing
that it meets your requirements.

Good Luck,
--- Nick

"Adam Clauss" <ca*****@tamu.edu> wrote in message
news:eC**************@TK2MSFTNGP12.phx.gbl...
Hmm I was afraid it might not be easy ;)

I'll look into those methods, see if either is doable.

I agree that the first method would be the 'best' to implement,
unfortunately it may be too late to go through and change that at this
point.

What I'm trying to accomplish here:
The app in question (not open source) compiles various scripts at runtime.
For users designing these runtime scripts, I would like for them to have
available all the classes, methods, etc in intellisense for them to use -
Right now they just have to memorize everything.

They cannot and do not need to actually BUILD against my assembly - the
program does that itself at runtime.

--
Adam Clauss
ca*****@tamu.edu
"mikeb" <ma************@mailnull.com> wrote in message
news:uZ**************@TK2MSFTNGP11.phx.gbl...
Adam Clauss wrote:
OK, lets say I have a C# Windows application. In it is a a series of
namespaces, all rooted for a certain namespace A.

For ex, the "using" directives would read something like:
using A;
using A.somenamespace;
using A.anothernamespace;

Now, other users will be using these namespaces. I would like for them
to
be able to take advantage of the intellisense features in Visual
Studio,
but I do not want to actually give them the source code (or give them a
DLL
with the necessary files). In other words, I want them to be able to code using it, but not actually be able to run it (does that make sense? I know
it seems a little wierd). In C++, this would simply be done by creating a header file. Unfortunately, I'm not familiar enough with C# to know
how to go about doing something similar.

So, is there anyway that this can be done?


In C#, the assembly is used to get the information that C/C++ compilers
used header files for. So to get intellisense, the coders need an
assembly of some sort.

Probably the cleanest way to do what you appear to want to do is to have
all of the methods you want them to code against be interfaces. That
way, you can compile an assembly that has nothing but the interface
declarations - no implementation code would be in that assembly.

They can reference that assembly for intellisense.

Your code with the classes that implement the interfaces would reference
the same assembly.

One drawback to this is that interfaces cannot contain static methods.
This might also require a big change in the design of whatever you're

doing.

Another option might be to use #if/#endif conditional compilation to
build version of your assemblies that have no real implementation. They
can code against those assemblies, then submit the code to whomever to
build against assemblies that have real implementations. I'm not sure
how well this would really work.

--
mikeb


Nov 15 '05 #4
Well, it isn't so much that I was prepared to go through and make header
files - but I was just using that as an example. Ideally I was hoping there
was some way I could generate some sort of... something.
AKA: take the assembly from my program, pass it through some tool or option
from Visual Studio and "extract" the parts from the namespace I need.

At first I thought the tlbexp might do just what I wanted... but after a
little research it seems it is just for COM projects. I was able to
generate a .tlb file with no problem, but I could not add a reference to
that file .tlb file in another project.

I will look into what I've been given here though.
Thanks for the suggestions.

--
Adam Clauss
ca*****@tamu.edu
"Nick Malik" <ni*******@hotmail.nospam.com> wrote in message
news:mbR%b.73274$4o.94122@attbi_s52...
Adam,

It is not difficult to create an interface. It is very much like a header. You create a new project, create the interface objects (like class
definitions, but containing no method code), and compile it. You distribute the resulting DLL.

To be certain that you are meeting the same interface expectations, you
should derive your objects from the same definitions.
Depending on the number of classes, this can take a little while, but not a terribly long period of time. You should be able to create an interface for each exposed class at a rate of one per 10-15 minutes. If you expose 80
classes, you can do this in a few days... (Really... count your classes...) If you were prepared to create header files, you can create interfaces.

For the interfaces that require static methods, simply create a "shell"
class (perhaps using the #ifdef idea that mikeb suggests) and include it in an alternate assembly (for ease of deployment).

One advantage to interface objects for the future: your users CAN compile
the code themselves... and you can call the code with confidence knowing
that it meets your requirements.

Good Luck,
--- Nick

"Adam Clauss" <ca*****@tamu.edu> wrote in message
news:eC**************@TK2MSFTNGP12.phx.gbl...
Hmm I was afraid it might not be easy ;)

I'll look into those methods, see if either is doable.

I agree that the first method would be the 'best' to implement,
unfortunately it may be too late to go through and change that at this
point.

What I'm trying to accomplish here:
The app in question (not open source) compiles various scripts at runtime.
For users designing these runtime scripts, I would like for them to have
available all the classes, methods, etc in intellisense for them to use - Right now they just have to memorize everything.

They cannot and do not need to actually BUILD against my assembly - the
program does that itself at runtime.

--
Adam Clauss
ca*****@tamu.edu
"mikeb" <ma************@mailnull.com> wrote in message
news:uZ**************@TK2MSFTNGP11.phx.gbl...
Adam Clauss wrote:

> OK, lets say I have a C# Windows application. In it is a a series of > namespaces, all rooted for a certain namespace A.
>
> For ex, the "using" directives would read something like:
> using A;
> using A.somenamespace;
> using A.anothernamespace;
>
> Now, other users will be using these namespaces. I would like for them
to
> be able to take advantage of the intellisense features in Visual
Studio,
but
> I do not want to actually give them the source code (or give them a

DLL
with
> the necessary files). In other words, I want them to be able to code using
> it, but not actually be able to run it (does that make sense? I

know it > seems a little wierd). In C++, this would simply be done by
creating
a > header file. Unfortunately, I'm not familiar enough with C# to know

how
to
> go about doing something similar.
>
> So, is there anyway that this can be done?
>

In C#, the assembly is used to get the information that C/C++

compilers used header files for. So to get intellisense, the coders need an
assembly of some sort.

Probably the cleanest way to do what you appear to want to do is to have all of the methods you want them to code against be interfaces. That
way, you can compile an assembly that has nothing but the interface
declarations - no implementation code would be in that assembly.

They can reference that assembly for intellisense.

Your code with the classes that implement the interfaces would reference the same assembly.

One drawback to this is that interfaces cannot contain static methods.
This might also require a big change in the design of whatever you're

doing.

Another option might be to use #if/#endif conditional compilation to
build version of your assemblies that have no real implementation. They can code against those assemblies, then submit the code to whomever to
build against assemblies that have real implementations. I'm not sure
how well this would really work.

--
mikeb



Nov 15 '05 #5

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

Similar topics

7
by: Bob | last post by:
Hi, I am trying to use BULK INSERT with format file. All of our data has few bytes of header in the data file which I would like to skip before doing BULK INSERT. Is it possible to write...
4
by: Kunle Odutola | last post by:
I'm trying to understand where the information in the META.INF directory including MANIFEST.MF etc is to be found for .NET assemblies. Also some projects such as Eclipse's OSGi kernel stores...
7
by: samuelberthelot | last post by:
Hi, I have the following in my asp page: <% response.write(Header) %> where Header contains HTML markup such ass <html> <body> .... I must write the code in the aspx file and not in the...
17
by: binjobster | last post by:
Hello everyone, I'm updating some documents that describes so many C/C++ functions/method(about 2500). But I'm not familiar with these codes. So I want to find such a utility can generate...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...

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.