|
Can you please elaborate. What exactly do you mean by hosting? Like in a web browser? I already do that.
|
|
|
|
|
No, like it is done by Window Tabifier. Start Excel and set parent of excel form to your form.
|
|
|
|
|
Hi
i don't know why the "Create GUID" tool is disable in my Visual Studio 2005 IDE.
also i could not found guidgen.exe in this path :
D:\Program Files\Microsoft Visual Studio 8\Common7\Tools
Can anybody help me about this issue ?
i'm using Microsoft Vidual Studio 2005 Professional Edition
Thanks
|
|
|
|
|
|
hdv212 wrote: also i could not found guidgen.exe in this path :
D:\Program Files\Microsoft Visual Studio 8\Common7\Tools
I think guidgen.exe is installed as part of the SDK.
Is there a copy here? D:\Program Files\Microsoft SDKs\Windows\...<version>...\bin
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
|
|
Hello everyone,
I'm building my own library. But I'm kind of stuck and it is really tough to explain, but I will try:
I have a class, let's call this X. X has an interface and a base class. X also inherets another class (called Y).
Now I call some base functions and give X as a parameter.
But I would like to know if it is possible in another baseclass?
To sketch it up in code, it looks like this now:
class X : Y, InterfaceX
{
public X()
{
}
bool function1(String txt)
{
return base.function1(this, txt);
}
}
class Y
{
bool function1(InterfaceX x, String txt)
{
return true/false;
}
}
And what I would like to have is something like this:
class X : Y (& Z), InterfaceX
{
public X()
{
}
}
class Y
{
bool function1(InterfaceX x, String txt)
{
return true/false;
}
}
class Z
{
bool function1(String txt)
{
return base.function1(this.getParent(), txt);
}
}
Is this possible, and if it is, how can I implement this?
Thank you very much.
|
|
|
|
|
Class X can't inherit from Y and Z because C# only supports single inheritance (unfortunately). You could have X inherit from Y, and Y inherit from Z. Or you could have X implement multiple interfaces.
Also you need the keyword "virtual" on the virtual methods in your base classes, and the keyword "override" on your overridden methods in the derived classes.
Another possibility is the Decorator design pattern, which lets you define inheritance (single or multiple) at runtime.
|
|
|
|
|
Thank you.
But the problem I have is that if I want to add a function to my Interface class and it is as simple as calling the base function with as parameter itself, shouldn't it be possible to do that in some kind of global class. Something like this:
class Main
{
public Main()
{
X x = new X();
x.function1("myText"); -> false
X2 x2 = new X2();
x2.function1("myText"); -> true
}
}
interface InterfaceX
{
int number { get; };
bool function1(String txt);
}
class X : Z, InterfaceX
{
public int number
{
get { return 5;}
}
public X(){}
}
class X2 : Z, InterfaceX
{
public int number
{
get { return 2;}
}
public X2() {}
}
class Z : Y,
{
public bool function1(String txt)
{
return base.function2(this.getParent(), txt);
}
}
class Y
{
public bool function2(InterfaceX x, String txt)
{
if(x.number < 3)
return true;
else
return false;
}
}
It's all about the this.getParent(), this doesn't work, but how can I get this working?
|
|
|
|
|
I'm not sure what you're trying to do, but this.getParent () will only work if:
1. Class Z (or an ancestor of Z) defines a getParent () method, and
2. This getParent () method returns InterfaceX (or a descendant of InterfaceX).
|
|
|
|
|
With the this.getParent() I would like to get the 'parent' of Z.
So if I make an X : Z I would like to get X.
And if I make an BlahBlah : Z I would like to get BlahBlah.
I'm trying to get some work of my back.
In stead of implementing all the functions (of the interface) inside of every class, I would like to make a base class which implements these functions.
|
|
|
|
|
If you put all the interface functions in a base class, they will automatically be available to all the derived classes.
If this doesn't work for you, you can define a class that implements all the interface functions, and define an instance of this in any class that that implements the interface. Then for each interface function, forward the call to this instance. This avoids having to re-implement the whole functions in each class that implements the interface.
For example:
interface InterfaceX
{
// Lots of interface function definitions...
}
class ImplementationOfInterfaceX : InterfaceX
{
// Implementation of each function...
}
class X : InterfaceX
{
ImplementationOfInterfaceX implX;
public int func1 (int par)
{
return implX.func1 (par); // I.e., a forwarded call instead of a 100-line function.
}
public float func2 (float par)
{
return implX.func2 (par);
}
...
}
Of course this would be much easier if C# allowed multiple inheritance. I'm hoping they will in a future version. It makes some things very easy. It seems to me they left it out because it allows complexity and confusion for some extreme contrived cases that no one in their right mind would do. Not a good justification for leaving it out (in my biased opinion).
|
|
|
|
|
The crux of the problem is that you want class Z to pass an item into a function that accepts an InterfaceX item, but class Z is not necessarily an InterfaceX . So, the only way to do it as-is is to do this messy kind of check. Ideally, you'd have the call to function2 be in a class that is an InterfaceX . Passing a Z that is not an InterfaceX won't work, so you'll have figure out how you want to handle that situation. Here's a class Z that should work:
class Z : Y
{
public bool function1(String txt)
{
if(this is InterfaceX)
return base.function2((InterfaceX)this, txt);
else
return false;
}
}
Keep It Simple Stupid! (KISS)
|
|
|
|
|
Thank you very much, I'll try to do it this way.
|
|
|
|
|
Hello,
I need to check and verify that some components are installed on the computer via C# code.
The components are:
MSMQ
IIS
I successfully implemented this issue using checking the existing of the relevant services.
and that they are running.
Is there any library that perform these checkings?
Is there any library that shows what do I have on this machine?
maybe an API that I can get the list from "Add/Remove Programs" of windows components?
Thanks,
Eitan
|
|
|
|
|
Hey all. I know I've done this in the past and I'm not having much luck searching online because it should...just work. I'm trying to save some javascript in a code behind and then calling it in the ASP.NET page using <%= Java%>. It's a simple time ticker that I want to reset all the time to countdown to Friday. My problem now is the string isn't accepting the \ as the escape for my double quotes.
public string Java
{
get
{
string java = "<script language="\"JavaScript\"">;";
java += "TargetDate =\" " + friday + "\"";
java += "BackColor = \"palegreen\";";
java += "ForeColor = \"navy\"; ";
java += "CountActive = true;";
java += "CountStepper = -1;";
java += "LeadingZero = true;";
java += "DisplayFormat = \"%%D%% Days, %%H%% Hours, %%M%% Minutes, %%S%% Seconds.\";";
java += "FinishMessage = \"It is finally FRIDAY!\"</script>;";
return java;
}
}
* There might be a few extra "'s here and there as a result of copying and pasting out of VS *
every time I run the debugger, the string reads ect....
What's really weird is if I replace the double quote with a single quote, then the string acts the way I want it to, but not with the double quotes! (<script language="JavaScript"> ect...)
Has anyone ever seen this problem before? Is it possible something got screwed up with my VS 2008 install?
<div class="ForumSig">"You're damned if you do, and you're damned if you dont" - Bart Simpson</div>
|
|
|
|
|
The debugger will always show the escape char '\'. Dont worry, it wont be in the output.
A few comments on your code:
1) Its Javascript. Java is a very different beast
2) Consider using a StringBuilder rather than lots of string concatenation using +=
3) Look at
Page.ClientScript.RegisterClientScriptBlock . Its preferable to simply trying to output some script to the page using the old-asp method of <%= %>
|
|
|
|
|
J4amieC wrote: Consider using a StringBuilder rather than lots of string concatenation using +=
If the strings are known at compile time, the compiler will generate one big string for you. Try compiling this and taking apart the EXE with ildasm and you will see what I mean.
using System;
class Foo
{
public static int Main(string[] args)
{
string s = "Hello, " + "world!";
Console.WriteLine(s);
return 0;
}
}
Cheers,
Vıkram.
Stand up to be seen. Speak up to be heard. Shut up to be appreciated.
|
|
|
|
|
As J4amieC says, you can use the Stringbuilder. But you can also use String.Format();
Very easy to use:
String javaScript = String.Format(@"
<javascript> etc. </javascript>
<and other="" stuff="" here=""></and>
{0} <- a variable
{1} <- another variable", variable1, variable2);
|
|
|
|
|
String.Format() uses StringBuilder internally.
|
|
|
|
|
I do a lot of dynamically created JavaScript in my ASP.Net development. I use a pattern similar to this:
protected void Page_PreRender(object sender, EventArgs e)
{
RegisterClientScript();
}
protected void RegisterClientScript()
{
if (!(Page.ClientScript.IsStartupScriptRegistered("myJS"))
{
StringBuilder js = new StringBuilder();
js.AppendLine("TargetDate = 'friday';");
js.AppendLine("BackColor = 'palegreen';");
js.AppendLine("ForeColor = 'navy';");
js.AppendLine("CountActive = true;");
js.AppendLine("CountStepper = -1;");
js.AppendLine("LeadingZero = true;");
js.AppendLine("DisplayFormat = '%%D%% Days, %%H%% Hours, %%M%% Minutes, %%S%% Seconds.';");
js.AppendLine("FinishMessage = 'It is finally FRIDAY!'");
Page.ClientScript.RegisterStartupScript(this.GetType(), "myJS", js.ToString(), true);
}
}
"We are men of action; lies do not become us."
|
|
|
|
|
Thank you everyone for the replies. I apologize, I'm not as familiar with Javascript yet, which is why up until now I would do more logic and coding in the C# behind pages and then just call the strings as needed. I've setup my page behind using the code above and it appears to insert the code properly, however it's still not working correctly. What I am trying to do is have the "TargetDate dynamically change to that week's upcoming friday. If I goto my asp page and put this in, it works just fine:
<script language="JavaScript">
TargetDate = '12/12/2008 12:00:00 AM';
BackColor = 'palegreen';
ForeColor = 'navy';
CountActive = true;
CountStepper = -1;
LeadingZero = true;
DisplayFormat = '%%D%% Days, %%H%% Hours, %%M%% Minutes, %%S%% Seconds.';
FinishMessage = 'It is finally FRIDAY!';
</script>
<script language="JavaScript" src="countdown.js"></script>
I then rip out the first script part and use the outlined code above. This will start the countdown timer but it can't find any of the settings I have in place. If I do a view source of the page, at the very bottom of the page I now see this:
<script language="JavaScript">
TargetDate = '12/12/2008 12:00:00 AM';
BackColor = 'palegreen';
ForeColor = 'navy';
CountActive = true;
CountStepper = -1;
LeadingZero = true;
DisplayFormat = '%%D%% Days, %%H%% Hours, %%M%% Minutes, %%S%% Seconds.';
FinishMessage = 'It is finally FRIDAY!';
</script>
I'm starting to wonder now if it makes more sense to just modify the "countdown.js" and put the switch statements in there to always update the date.
Again, thank you for all of your help!
"You're damned if you do, and you're damned if you dont" - Bart Simpson
|
|
|
|
|
Is there any solution to run PowerShell 1.0 in C# remotely? Can't run PowerShell 2.0 in Windows XP, right?
Thank you!
|
|
|
|
|
Hi all
I am trying to take an XML response from a web server and putting it into a Dataset
I am using a streamreader to pass the xml stream to the readxml method of the dataset, however I am finding that I am not getting all the data..
this might explain myself better.. if i do this:
HttpWebResponse oResp = (HttpWebResponse)myReq.GetResponse();
StreamReader oResultSR = new StreamReader(oResp.GetResponseStream(), encoding);
sMessage = oResultSR.ReadToEnd();
TextWriter tw = new StreamWriter(@"c:\hmmm.txt");
tw.WriteLine(sMessage);
tw.Close();
that works fine and my text file has all the xml data I need
however if i do this (which i want):
HttpWebResponse oResp = (HttpWebResponse)myReq.GetResponse();
StreamReader oResultSR = new StreamReader(oResp.GetResponseStream(), encoding);
DatasetXML[a].ReadXml(oResultSR);
DatasetXML[a].WriteXml(@"c:\hmmm.xml");
it only gives me the 1st node of the xml and not the rest
anyone know why?
|
|
|
|