|
It shows that it selected has a TabPage I can view all the info for that tabpage and everything though the debugger.
It's weird that it stops and that line though, it skips the rest of the places where I have used tabControl1.SelectedTab .
|
|
|
|
|
SelectedTab must be null, unless tabControl is. That's the only explanation for the error.
Assuming the error is not thrown by the cast, and the Tag might be null ?
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Thanks, I checked out the debugging info and saw that Tag was not even showing up in it, so I created another class to extend the TabPage and added an IsFileReadOnly variable and it seems to work fine now.
|
|
|
|
|
Great - that exception always means something is null, I didn't realise it would be thrown by the cast attempt, that occured to me at the last minute. I'd always use the Convert. or a TryParse ( bool.TryParse ? ) to do conversions, and check for null first.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hello,
I'm a bit new at in-depth IE programming, and am having a bit of trouble with a couple of IE browser extensions (getting them to talk to each other).
The first one is a C++ Browser Helper Object (BHO).
I have a class (MyClass) that has a method called "ReferenceMe" that calls the browser's "PutProperty" method to save a reference to the BHO instance in IE.
Theoretically other COM object should be able to call IE's "GetProperty" method to retrieve this reference and use it to invoke methods in the BHO.
I also have another method in the BHO called "toggleActiveState" that just sets a boolean flag. That's the method I want to invoke from outside of the BHO.
Then I have a C# Explorer Toolbar object. I'm trying to call the BHO's "toggleActiveState" method from the C# code.
The problem I'm having is that I can't figure out how to invoke that "toggleActiveState" method in the C++ BHO from the C# code.
When I try to call the GetMethod function call in C# to retrieve the method's reference, it returns NULL.
Below are snippets of my code...
Here's the C++ code...
<br />
HRESULT MyClass::ReferenceMe()<br />
{<br />
BSTR bstrThisKey = SysAllocString(L"MyClass_IDisp");<br />
VARIANT vThis;<br />
HRESULT hr = S_OK;<br />
<br />
if (!m_spWebBrowser)<br />
hr = S_FALSE;<br />
else<br />
{<br />
VariantInit(&vThis);<br />
vThis.vt = VT_DISPATCH;<br />
vThis.pdispVal = static_cast<IDispatch*>(this);<br />
<br />
if (FAILED( m_spWebBrowser->PutProperty(bstrThisKey, vThis) ))<br />
{<br />
hr = S_FALSE;<br />
}<br />
}<br />
<br />
VariantClear(&vThis);<br />
SysFreeString(bstrThisKey);<br />
return hr;<br />
<br />
}<br />
<br />
void STDMETHODCALLTYPE MyClass::toggleActiveState()<br />
{<br />
m_bActive = !m_bActive;<br />
}<br />
<br />
And here's my C# code...
<br />
private void toggleBHO()<br />
{<br />
Object pvarPBHO = null;<br />
pvarPBHO = Explorer.GetProperty("MyClass_IDisp");<br />
if (pvarPBHO != null)<br />
{ <br />
MessageBox.Show("About to call GetType.");<br />
Type typExternal = pvarPBHO.GetType();<br />
if (typExternal != null)<br />
{ <br />
MethodInfo mthInv = null;<br />
MessageBox.Show("About to call GetMethod.");<br />
<br />
<br />
mthInv = typExternal.GetMethod("toggleActiveState");<br />
if (mthInv != null)<br />
mthInv.Invoke(pvarPBHO, null);<br />
else<br />
MessageBox.Show("GetMethod returned NULL.");<br />
}<br />
else<br />
MessageBox.Show("GetType returned NULL.");<br />
}<br />
else<br />
MessageBox.Show("GetProperty returned NULL.");<br />
}<br />
Perhaps my whole approach to this is off. Is there a better way to get these two COM objects to talk to each other?
Thanks very much!
|
|
|
|
|
I'm using local ftp -using windows XP- I can access it through my browser ftp://localhost/ but when I'm trying to access it through my C# program I had an exception and here is my code
FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp://localhost/");
request.Method = WebRequestMethods.Ftp.UploadFile;
//request.Credentials = new NetworkCredential("anonymous",
// "janeDoe@contoso.com");
request.Credentials = new NetworkCredential(username, password);
StreamReader sourceStream = new StreamReader(filePath);
byte[] fileContents = Encoding.UTF8.GetBytes(sourceStream.ReadToEnd());
sourceStream.Close();
request.ContentLength = fileContents.Length;
Stream requestStream = request.GetRequestStream();
requestStream.Write(fileContents, 0, fileContents.Length);
requestStream.Close();
FtpWebResponse response = (FtpWebResponse)request.GetResponse();
I get an "Invalid URI" at request.GetResponse() so can anyone figure what am doing wrong
thanks in advance
"Our deepest fear is not that we are inadequate. Our deepest fear is that we are powerful beyond measure" -Nelson Mandela-
|
|
|
|
|
Hi all.
I am new to socket programming .i have two application created on .net 2 version and this two application is listening to single port .
First application sends the data and second application recieves the data.
Now i am getting following error
Only one usage of each socket address (protocol/network address/port)
is normally permitted
Can any pls help
Thanks in Advance
Regards
DilipRam
|
|
|
|
|
One of your applications, or some other app, is already using whatever port you picked. You didn't say which app is throwing the exception or what is was doing at the time of the error.
|
|
|
|
|
Sorry for not mentioning it clearly.My first application opens a connection at the formload event and then access the send message method which is written in the class file.My second application also opens a connection in its form load event and access recieve method which is written in the class file.Both application are accessing same port.when i load the first application , the first application shows the error.
Hope i am clear this time.
Regards
DilipRam
|
|
|
|
|
You've got both application opening the same port. That won't work.
The first application will launch and open the port. The second will fail every time because you can't have two applications listening on the same port.
Now, if you launch the first application and it fails, then some other application already has the port open, or, the port was never closed and released properly on the first run of your app.
|
|
|
|
|
Thanks for the reply.But then if i want a application which should send some data and another application should recieve that same data, and after recieving data , the recieved application should send the data back to send application, then how can i do it.Should i use different ports.If i use different ports then how can each application recieve the data.Can you pls explain it.
Regards
DilipRam
|
|
|
|
|
They talk back and forth on the same port. The server listens on a port, the client connects to the server on that port, then, in a simple example, they both use NetworkStreams to talk back and forth to each other, just like reading/writing a text file.
If you want examples, Google for "C# Chat" and you'll come up with tons of them.
|
|
|
|
|
Thanks Very much for you reply.I have added two ports one remote port and second a local port and now its working fine
Regards
DilipRam
|
|
|
|
|
Could anyone tell me how to make it so the form window is always on top?
-----
*** Never give me an answer having anything to do with Visual Studio. I don't have this because I have two computers, one being my dad's mac, which is connected to the internet, the other being my pc, which is, sadly, not connected to the internet. The setup for the Visual C# program I think is called a "bootstrap" program, and it needs to connect to the internet to install the program. THEREFORE I cannot install this program onto my pc.***
|
|
|
|
|
Hi Max,
The relevant properties would be Form.TopLevel and TopMost;
and there is the possibility to use ShowDialog() rather than Show().
It depends on what exactly it is you want.
|
|
|
|
|
max29297 wrote: The setup for the Visual C# program I think is called a "bootstrap" program, and it needs to connect to the internet to install the program.
What version?
|
|
|
|
|
The Express ones by default download what they need, just a simple bootstrapper to start things going, you can download CD images of them though to burn.
|
|
|
|
|
THanks Ed!
|
|
|
|
|
max29297 wrote: THEREFORE I cannot install this program onto my pc.***
You can download a CD image of Visual C# Express and burn that to a CD so you don't have to be connected to the internet.
|
|
|
|
|
FYI: Full iso images of the express editions can be downloaded here. Unlike the bootstrappers you shouldn't need an internet connection to install.
http://msdn.microsoft.com/vstudio/express/support/install/[^]
--
You have to explain to them [VB coders] what you mean by "typed". their first response is likely to be something like, "Of course my code is typed. Do you think i magically project it onto the screen with the power of my mind?" --- John Simmons / outlaw programmer
|
|
|
|
|
How do you run an application within another application? I think it has something to do with the Process class...
-----
*** Never give me an answer having anything to do with Visual Studio. I don't have this because I have two computers, one being my dad's mac, which is connected to the internet, the other being my pc, which is, sadly, not connected to the internet. The setup for the Visual C# program I think is called a "bootstrap" program, and it needs to connect to the internet to install the program. THEREFORE I cannot install this program onto my pc.***
|
|
|
|
|
one app can launch another app using the Process class,
the simplest approach is Process.Start("myfolder\\prog.exe");
more options are available by instantiating a Process object, and using StartInfo property.
The second process is a process in its own right, it does not run inside the first process
(whatever that would mean).
|
|
|
|
|
I need help in making a small program
I am trying to make a program that sits on the desktop never on top of anything unless it is called that is like a start button. when clicked it will open the start menu.
The only this is I need help getting the actual code that will bring it up.
Yesterday I saw a piece of code that will tell the computer that ctr + esc has been pressed when you click on it and it will open it up at where you click but it was in visual basic and I know C#
|
|
|
|
|
Post a link and some of us can help translate it if needbe if it does exactly what you want.
|
|
|
|
|
ok I'll try to find it again
|
|
|
|