|
Is Global Assembly Cache similar to COM?
It seems you register objects which can be used by other applications. Other applications can then create objects by referencing the GAC?
|
|
|
|
|
COM is a technology. GAC is a location. COM registration is a lot more involved, with entries in the registry, etc. GAC is a common location to place assemblies, there is no registration or entries in the registry.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
ok so does it make sense to use COM in C# applications?
|
|
|
|
|
Well that depends.
Do you need to expose you assemblies to/as COM?
In other words is there a "legacy" COM based component(s) that needs to use your C#/.Net
data/object model?
If yes => then YES it makes sence to expose your "whatever" as COMVisible.
Else => NO it does NOT make sence.
|
|
|
|
|
ok so if I had developed in .NET a bunch of data access helper classes for a particular type of database and wanted it used by other .NET applications, each application would need the DLL right?
If I had an application in C++ MFC that could use that code, it may make sense to make it COMVisible and then the C++ application could get at the methods?
|
|
|
|
|
Ryan Minor wrote: each application would need the DLL right?
Each application would need to reference the assembly, whether it is in the GAC, in the local folder, or elsewhere.
How the Runtime Locates Assemblies[^]
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Mark Nischalke wrote: GAC is a location
It's also the reaction I have when I see some of these questions...
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
and what is that supposed to mean, twit?
|
|
|
|
|
Ryan Minor wrote: and what is that supposed to mean, twit?
Whatever you want it to mean, Sparky...
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
modified on Saturday, January 30, 2010 3:12 PM
|
|
|
|
|
read "how to answer a question" where it talks about insults jackass
|
|
|
|
|
Ryan Minor wrote: read "how to answer a question" where it talks about insults jackass
So far, you're the only one launching insults (and just in case you're having a hard time keeping count, that makes twice that you've called me a name).
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
modified on Saturday, January 30, 2010 3:12 PM
|
|
|
|
|
Hello everyone!
To illustrate my question, here is a minimal amount of code showing off the problem:
#define TEST
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1 {
class Program {
static void Main(string[] args) {
if (true) {
DoSomething();
}
#if TEST
else {
}
#endif
}
private static void DoSomething() {
throw new NotImplementedException();
}
}
}
I have kept the indentation that Microsoft Visual C# provides.
Look at the else-block. Its indentation is wrong. It should be indented to the same position as if (true) .
My guess is that MSVC# thinks that the else belongs to the compiler directive #if .
Is there any way to make MSVC# indent the else -line correctly? (I'd prefer not to do it manually since I use the in-built Reformat Document function.)
I am using Visual C# 2008 SP1 by the way.
Thanks in advance,
F2
modified on Friday, January 29, 2010 4:31 PM
|
|
|
|
|
|
Formatting is what makes code easy to read. I have a file with thousands of lines, many consecutive lines are surrounded by #if/#else directives - it makes it very difficult to read when the indentation is wrong.
If it works correctly for you then I guess it comes down to formatting settings. I will try to tinker with those settings.
|
|
|
|
|
Then consider structuring your code or rearchitecting to eliminate the need for all the #if/#else. You can use some patterns, like Factory, IoC, Stategy to elimiate this type of clutter and make your code more readable, extensible and maintainable.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Works fine for me. I suspect it has to do with this:
F2dk wrote: I am using Visual C# 2008 RC1
Why are you using Release Candidate software two years after the full product was launched?
All those who believe in psycho kinesis, raise my hand.
My 's gonna unleash hell on your ass. tastic!
|
|
|
|
|
Sorry, I meant SP1.
But it works for you? Hmm, that's interesting.
|
|
|
|
|
Yes fine - try removing the #IF and #ENDIF lines. If a reformat document does not fix the formatting, then you may have an unfixed problem in your code - <TeachGrannyToSuckEggsMode >this can stop formatting working correctly.</TeachGrannyToSuckEggsMode >
Good Luck!
All those who believe in psycho kinesis, raise my hand.
My 's gonna unleash hell on your ass. tastic!
|
|
|
|
|
Okay, I just figured it out.
In Options -> Text Editor -> C# -> Formatting -> New Lines, I have "Place 'else' on a new line" disabled.
Enabling it fixes the problem. (But I don't want to enable it, obviously.)
I consider this a bug in MSVC#. I wonder if it persists in VC# 2010.
|
|
|
|
|
F2dk wrote: Enabling it fixes the problem. (But I don't want to enable it, obviously.)
How can you consider it to be a bug? It's working as designed.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
By disabling "Place 'else' on a new line" I get code looking like this:
} else {
(on one line) - That is what I am used to.
But due to C#'s syntax, I can force something in between the } and the else .
For example, a comment.
if (true) {
DoSomething();
}
else {
In this case MSVC# actually doesn't know what to do about the else , so if I change its indentation and Format the document (Edit -> Advanced) then it doesn't change else 's indentation.
This is in my opinion a bug (or lack of feature) since you obviously would want the else-clause to be indented to the same level as the if-clause.
You could also put an #if directive before an else-clause. In this case MSVC# insists on indenting the else-clause by exactly 1 space.
if (true) {
DoSomething();
}
#if DEBUG
else {
Again, I would expect the else-clause to be indented to the same level as the if-clause. Would you disagree with that?
I fully understand why it doesn't happen though. (After the compiler has parsed the #if directives, all it reads is } else { and therefore it places a space before the else-clause just like I told it to by disabling the new-line-before-else option.)
But I definitely consider it a bug. Don't you?
|
|
|
|
|
Ew, } else { is ugly and unreadable.
|
|
|
|
|
No it isn't; it works great for me, e.g.:
if (install) {
key1.Write(null, menuText);
key2.Write(null, command);
} else {
key2.Delete(null);
key1.Delete(null);
}
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. [The QA section does it automatically now, I hope we soon get it on regular forums as well]
|
|
|
|
|
And I thought VB was ugly
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
It is
Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|