|
Worked like a charm.
Now to write an article.
He was a snowflake, like other "unique" snowflakes, falling down, getting stepped on, and pushed aside to disappear.
|
|
|
|
|
Hello all,
I'm new to remoting and have been given a task which I'm having trouble with.
We have a bunch of windows services that perform various tasks, running on a remote computer. We need a way to interrogate the services remotely and return a number of given values from variables/props INSIDE the service. This will then be used to create a dashboard of values from our services at any given time so we can see they are all working properly.
I have setup a test program that uses a simple windows service as the component host, which registers my remote object to be instantiated by my test client program.
My question is, how do I refer back from the remoting object to my service to obtain the values required? As far as I can see, the remote object itself has no knowledge of the component host that it was instantiated from. I've read lots of text on remoting but nothing seems to mention access to the component host of the remoting object.
I've tried using ManagementObject and iterating through the services running, and I can find my service, but I can't find a way from there to access the custom properties of my service class, only the base properties of all services. Is there another way to obtain this information using the ManagementObject? Or is there a way from my remote object to reference back to its component host?
I tried using GetActiveObject() as well but that seems to not work for services
Any help would be much appreciated, there's probably a easy way to do this that I can't see.
Thanks
|
|
|
|
|
Im trying to read a xml-file with a StreamReader. For the moment I'm using the following code.
<br />
streamReader = new StreamReader(stream, System.Text.Encoding.Default);<br />
string feedData = streamReader.ReadToEnd(); <br />
I'm using System.Text.Encoding.Default so that I can get some swedish characters working. But I'm having problem when reading a xml-file that's encoded with UTF-8. In the beginning of the xml-files you have the encoding for the file, so I have tried this code:
<br />
streamReader = new StreamReader(stream, System.Text.Encoding.Default);<br />
string feedData = streamReader.ReadLine();<br />
if(feedData.indexOf("UTF-8") != -1)<br />
streamReader = new StreamReader(stream, System.Text.Encoding.UTF-8);<br />
<br />
string feedData += streamReader.ReadToEnd(); <br />
My plan was to read the first line, check if it's encoded with UTF-8 and then change the stream. This doesnt work at all... Is there anyway you can change the encoding for a stream once it's initialized or can you encode the string afterwards?
|
|
|
|
|
Deal ALl,
How would I be able to generate MS Project file .Any Hint/idea would be appreciated.
Regards,
Lq
|
|
|
|
|
Dear gurus,
currently I learn how to write my programs based on plugin-technology in c# and I have a lot of open questions.
Can anybody suggest a good book on this subjet?
Thanks in advance
|
|
|
|
|
There are lots of articles on this subject here at CP. Just enter plugin in the search box to find the list of articles.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Dear friends,
I used the .NET-Treeview [ System.Web.UI.WebControls.TreeView ] to display XML-Data in a tree. This works so far.
But unfortunately there are vertical spaces between the Tree-Nodes, which I cannot remove.
In the MSDN I only found the two members of the TreeNodeStyle-class:
ChildNodesPadding and VerticalPadding
But these properties have the default-value 0,
so I wasn´t able to remove the vertical spaces with setting these properties.
You can see the problem here[^]
Do you know this problem, and know how to remove the vertical spaces?
Thank you,
J.
|
|
|
|
|
Sounds like you need to owner draw your control, which means you need to write all the code that renders a treeview. Is it really worth it ?
What happens if you change those properties ? Can you make them negative ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"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 Christian,
when
ChildNodesPadding = 0;
and
VerticalPadding = 0;
the TreeView looks like on the picture.
And when I make ChildNodesPadding and VerticalPadding negative, .NET throws an Exception.
Do you know some other parameters I can use,
or how to get this tree look better?
Greetings,
Jan
-- modified at 7:01 Wednesday 28th March, 2007
|
|
|
|
|
I need open new form and close that form, from wich it was opened.
How to do it?
|
|
|
|
|
You create an instance of the form and call ShowDialog(). Then you call Close() to close it.
I recommend buying a book to help you learn this sort of entry level stuff.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"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 )
|
|
|
|
|
thak you for advice
What book you recomend?
|
|
|
|
|
Inside C# used to be good, but there's no 2.0 version. I'd look for a Microsoft Press book, tho, just choose whatever seems to be aimed at your level.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"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 )
|
|
|
|
|
I'm writing a Windows Explorer-like clone for myself, and I'm running into a problem with empty disk drives.
When I run the application, by building the project, it works as expected. However, if I run the executable directly, I get an error window titled:
".NET-BroacastEventWindow.1.0.3300.0.1: ExplorerPlus.exe - No Disk."
Normally, this error references drive A:. (Which, of course, is empty.)
However, I wrap the appropriate calls in try...catch blocks. In fact, if I remove the try...catch blocks, this error will pop-up before .NET displays its message about the un-caught exception.
This happens for both debug and release versions of the executable. Running the executable directly results in these errors whenever the application accesses an empty drive. However, when the executable runs as a result of the project being built, it runs just fine.
|
|
|
|
|
Hi,
in my Explorer replacement, I used the native function SetErrorMode to avoid
the low-level error reporting taht occurs by default on empty drives.
It works on all .NET versions (tested on XP only).
This is part of my code:
using (new LP_SetErrorMode(ErrorModes.FailCriticalErrors)) {
}
using System;
using System.Runtime.InteropServices;
namespace LP_Core {
[Flags]
public enum ErrorModes {
Default=0x0,
FailCriticalErrors=0x1,
NoOpFaultErrorBox=0x2,
NoAlignmentFaultExcept=0x4,
NoOpenFileErrorBox=0x8000
}
public struct LP_SetErrorMode : IDisposable {
private int oldErrorMode;
public LP_SetErrorMode(ErrorModes mode) {
oldErrorMode=SetErrorMode((int)mode);
}
void IDisposable.Dispose() {
SetErrorMode(oldErrorMode);
}
[DllImport("kernel32.dll")]
private static extern int SetErrorMode(int mode);
}
}
Hope this helps.
|
|
|
|
|
Very ingenious, thank you. It works perfectly.
|
|
|
|
|
Still trying to build a VS60 project in .NET 2003
Now I"m compiling and getting a link error: LINK : fatal error LNK1104: cannot open file 'mfc42.lib'
I thought mfc42.lib would be a known default lib. I also cannot find it in my project to see where its included.
Any ideas? TIA
-C
|
|
|
|
|
Once again.. I solved my own problems. I had a library built in VS60 that was incompatible.
|
|
|
|
|
We have alot of VS60 code that we want to start using .NET 2003 as our build
environment. I figure, I load the project and see what happens.
First error is about CString.
'CString' : is not a member of 'ATL::CStringT<basetype,stringtraits>'
with
[
BaseType=char,
StringTraits=StrTraitMFC_DLL<char>
]
Does .NET use CString or only CStringT? Anyway to have it accept CString or do we need to go and do a global replace
for CString w/ CStringT?
Also, alot of our code is for DLLs, any issues w/ the export functions etc?
Any ideas on this or other porting issues we may run into would be
appreciated. Thanks.
-C
|
|
|
|
|
This question has nothing to do with .NET, it's a C++ question.
Wheatbread wrote: Does .NET use CString or only CStringT? Anyway to have it accept CString or do we need to go and do a global replace
for CString w/ CStringT?
You may need a different #include. A #define would change the definition globally if this is what's needed.
Wheatbread wrote: Any ideas on this or other porting issues we may run into would be
appreciated. Thanks.
If you've ever written any code that expects to reuse a variable declared inside a for loop ( as in for(int i =0;... ), this will need to be changed, because VC2002 onwards corrects this error in VC6, with regard to standard C++.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"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 )
|
|
|
|
|
I discovered
.NET doesn’t like CString::CString((LPCTSTR)o_pBuffer)
Prefers (LPCTSTR)o_pBuffer
Weird.
|
|
|
|
|
You haven't done anything with .NET, so stop referring to it! When you start writing C++ code using CLI or the .NET classes, then you can start, but until then, you're using plain old Visual C++ 2003.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Well, part of this is down to MS's original confusing name for VC++ 7.x, i.e., Visual C++ .NET 2003 - which means it's Visual C++ that subsumes MFC, ATL, etc. plus the new .NET.
However, in the current context it would be clearer to refer to perhaps VC++ 7, 8 or 2003, 2005.
Kevin
|
|
|
|
|
Wheatbread wrote: Any ideas on this or other porting issues we may run into would be
appreciated.
Google on "breaking changes in visual c++". You'll see a few useful MSDN links. Ditto "Breaking chages in MFC."
Kevin
|
|
|
|
|
hello,
I created a win32 project(precompiled headers, console application). This was created to create a service( for which i used SERVICE_TABLE_ENTRY, SERVICE_STATUS, SERVICE_STATUS_HANDLE, etc... required structures and methods).
Environment used:
Windows XP, VC++.Net2005.
Should work on:
I want to make this exe to run on windows 95,98, XP, 2000 and Vista.
my stdafx.h file contains:
#pragma once
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#include <stdio.h>
#include <tchar.h>
// TODO: reference additional headers your program requires here
#pragma warning (disable:4430)//... i added this, since i was getting this error. and in msdn this //was given as its solution.
To this project, i have added two more files:
1) USBActivity.h
2) USBActivity.cpp
In USBActivity.cpp the hierarchy of headers included is as follows:
#include "stdafx.h"
#include <initguid.h>
#include "stdio.h"
#include <setupapi.h>
#include <dbt.h>
#include "afxcmn.h"
#include "cfgmgr32.h"
#include "Blowfish_Data_FileEncrpt.h"
#include "USBActivity.h"
The project properties are set as: Use windows Standard libraries, WIN32;_DEBUG;_CONSOLE as preprocessor definitions, Basic Run-TimeChks: Both (/RTC1, equiv. to /RTCsu) , RunTime-Library --> Multi-threaded Debug (/MTd), Use Precompiled Header (/Yu), Linker+AdditionalDependencies-->setupapi.lib.
I am getting following build errors:
Compiling...
stdafx.cpp
Compiling...
Blowfish_Data_FileEncrpt.cpp
DataSentinelService.cpp
d:\microsoft visual studio 8\vc\platformsdk\include\commctrl.h(29) : error C2146: syntax error : missing ';' before identifier 'HRESULT'
d:\microsoft visual studio 8\vc\platformsdk\include\prsht.h(97) : error C2065: 'CALLBACK' : undeclared identifier
d:\microsoft visual studio 8\vc\platformsdk\include\prsht.h(97) : error C2065: 'LPFNPSPCALLBACKA' : undeclared identifier
d:\microsoft visual studio 8\vc\platformsdk\include\prsht.h(97) : fatal error C1903: unable to recover from previous error(s); stopping compilation
DoubleBuffering.cpp
SHA.cpp
USBActivity.cpp
d:\microsoft visual studio 8\vc\platformsdk\include\commctrl.h(29) : error C2146: syntax error : missing ';' before identifier 'HRESULT'
d:\microsoft visual studio 8\vc\platformsdk\include\prsht.h(97) : error C2065: 'CALLBACK' : undeclared identifier
d:\microsoft visual studio 8\vc\platformsdk\include\prsht.h(97) : error C2065: 'LPFNPSPCALLBACKA' : undeclared identifier
d:\microsoft visual studio 8\vc\platformsdk\include\prsht.h(97) : fatal error C1903: unable to recover from previous error(s); stopping compilation
Generating Code...
DataSentinelService - 8 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I guess the error is because of :
--> calling a function in an SDK header file that is currently not supported in current build environment.
Could anybody help me out... in fixing this problem.
I have also seen the project given at the following link: http://www.codeproject.com/system/RemoveDriveByLetter.asp?df=100&forumid=294340&exp=0&select=1822184&tid=1815457#xx1822184xx
Here, it is given in vc++ 6. and when i compared the build environment everything was same.
In order to enumerate enumerate all the USB devices connected to PC, using a windows service... i have to use setupAPI in order to get setupDiGetDevClass etc methods.
I also tried with including windows.h file in stdafx.h. but it was also not helpful. since was included by-default. And on including it again i am getting the following error:
d:\microsoft visual studio 8\vc\atlmfc\include\afxv_w32.h(16) : fatal error C1189: #error : WINDOWS.H already included. MFC apps must not #include <windows.h>
Is there any other alternative?
Thanks
Anee
Anee
|
|
|
|
|