|
Two ways to do it, neither of them good or easy...
- A packet sniffer running between the WebService and the Client. Not a good idea and not easy to pull out and log the information you want.
- Write a shim WebService that exposes all the same methods and parameters that forwards requests back and forth to the real WebService, while logging what's called and with what parameters. Also, not good, not easy, and is a duplication of effort because you have to duplicate the original WebService interface exactly.
The best method is to write the logging code into the original interface as you write it. Then you could at least configure it to look at it's configuration file and wee if it needs to log information or not.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I have seen various framework functions that take piped enumerated properties, by this I mean :
object o = FunctionName(Property.Value1|Property.Value2|Property.Value3)
I would also like to be able to do this through property accessors aswell as functions, a framework example of this is the System.Windows.Forms.Anchor property :
label1.Anchor = (AnchorStyles.Bottom | AnchorStyles.Right);
How can I implement this type of functionality into my own code?
post.mode = postmodes.signature;
SELECT everything FROM everywhere WHERE something = something_else;
> 1 Row Returned
> 42
|
|
|
|
|
Those values are not "piped" as you call it, it's the C# OR operator. They're just bit flag values OR'd together to come up with a composite value. All the constants are usually defined in an enum or are public constants in your class. For instance if the values of the constants your provided in your example were:
public class AnchorTest
{
enum AnchorStyles
{
Bottom = 0x0001;
Right = 0x0002;
Left = 0x0004;
Top = 0x0008;
}
}
Your property would then take a parameter and/or return a parameter of type AnchorStyles:
public class AnchorTest
{
private AnchorStyles m_AnchorStyle;
enum AnchorStyles
{
Bottom = 1,
Right = 2,
Left = 4,
Top = 8
}
public AnchorStyles AnchorStyle
{
get { return m_AnchorStyle; }
set { m_AnchorStyle = AnchorStyle; }
}
}
Now, when you OR, or '|' your values together, you'll get the values added together. 1 OR 2 will equal 3, 1 OR 4 will equal 5, 1 OR 2 OR 4 OR 8 will equal 15.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi everyone,
I have a AxSHDocVw.AxWebBrowser on a Form in my Windows Forms application. Now, is it possible somehow to create an HTML document on the fly (programmatically from my Windows Forms application) that will be displayed instead of navigating to an existing document using AxWebBrowser.Navigate(...) ?
Thanks for any clues in advance!
Rado
|
|
|
|
|
Funnily enough I was doing this very same thing today.
I couldnt find a way to, for example, pass in a HTML string and get the browser to render it.
So, using the data from the form components I created a HTML string and used a FileStream to write the this to a temporary file, I then used :
object obj = null;
myBrowser.Naviagate(pathToFile, ref obj, ref obj ref ob ref obj, ref obj)
Note : I may have not typed in the right amount of "ref obj" as I am doing this from memory.
post.mode = postmodes.signature;
SELECT everything FROM everywhere WHERE something = something_else;
> 1 Row Returned
> 42
|
|
|
|
|
What you're both going to need to learn to use is MSHTML. Which is basically DHTML. So if you already know DHTML it makes it really easy. If you don't know DHTML but you understand XML, then you shouldn't have too many problems. So what you're going to need to do is get ahold of the Body element of the Document page and insert the HTML that you need by either creating the elements on the fly which is the most correct way, or by doing something like body.InnerHTML = "my html stuff". If this doesn't make any sense I'll try to find you some links that I used to learn it.
|
|
|
|
|
Navigating to a local file is fine, in fact, Reflector used to do this in a version a while ago (I haven't checked to see how Lutz is doing it now).
- Nick Parker My Blog | My Articles
|
|
|
|
|
That's the way I went in the end, because I didn't want to write to a temporary file each time. I have created an HTML template document with a few elements, like a header and text field, and then used MSHTML to locate these elements and set their innerHTML attributes.
Looked like a more elegant way for my purpose.
If anyone needs the code, I can post it here, it was just a few lines.
Rado
|
|
|
|
|
And of course you can just navigate to "about:blank" and it will load an empty document immediately.
Judah Himango
|
|
|
|
|
I am trying to read the memory being used by a process but I can't quite figure out how to do it (or if it's even possible). I can get a reference to the process using Process.GetProcessesByName and I can get the base address using Process.MainModule.BaseAddress (which returns a IntPtr). I thought that by using IntPtr.ToPointer() and casting to a char* I would be able to read the memory as a stream of chars but it doesn't work because it always throws a NullReferenceException when I try and dereference the pointer.
Can anybody help me out here?
Thanks
class Class1
{
[STAThread]
static unsafe void Main(string[] args)
{
Process[] p = Process.GetProcessesByName("notepad");
ProcessModule pm = p[0].MainModule;
Console.WriteLine(pm.BaseAddress);
char* ptr = (char*) pm.BaseAddress.ToPointer();
char c = *ptr;
Console.WriteLine(c);
Console.ReadLine();
}
}
"Where do we go to get our good name back?...we go where we always go when a dramatic change is needed. We go to the ballot box" - Al Gore 5/26/04
|
|
|
|
|
|
Writing a trainer
"Where do we go to get our good name back?...we go where we always go when a dramatic change is needed. We go to the ballot box" - Al Gore 5/26/04
|
|
|
|
|
That still doesn't explain what you are trying to do with your example above.
- Nick Parker My Blog | My Articles
|
|
|
|
|
|
Yes, thank you, that is what I meant. Sorry I should have been clearer.
"Where do we go to get our good name back?...we go where we always go when a dramatic change is needed. We go to the ballot box" - Al Gore 5/26/04
|
|
|
|
|
|
Thanks, that's a great article. I have got as far as using PInvoke with the OpenProcess and ReadProcessMemory functions, but the article doesn't use the WriteProcessMemory which I'm having trouble with. I got it working and got it to change the area of memory which I am sure is the right place, but it hung the game I'm not sure if I'm just messing with the wrong place or if I'm doing something wrong. Oh well. I was only doing it for a bit of fun.
"Where do we go to get our good name back?...we go where we always go when a dramatic change is needed. We go to the ballot box" - Al Gore 5/26/04
|
|
|
|
|
I work for a printing company and am writing a program (in C#) which displays an image of what is to be printed on our press. However i need the program to also print the image on a normal inkjet printer as well. This image needs to be printed at a resolution of 240 dpi.
Does anyone know if it is possible to set the printers resolution at design time?
|
|
|
|
|
I have a class library for which I am trying to discover it's methods.
The first class works fine since it has all methods marked public. The second method does not because it has all of its methods marked protected.
Here are the two BindingFlags attempts I've tried:
MethodInfo[] items = assembly.GetMethods
(BindingFlags.Public|BindingFlags.Instance|BindingFlags.NonPublic|BindingFlags.Static);
Is there a BindingFlags enum I can use to expose those protected methods or do I have to do something a bit more complex?
Thanks
Michael
This signature left intentionally blank
|
|
|
|
|
Try the following, it works for me:
BindingFlags bf = BindingFlags.Instance | BindingFlags.Public |
BindingFlags.NonPublic | BindingFlags.FlattenHierarchy;
- Nick Parker My Blog | My Articles
|
|
|
|
|
Well, I tried this and it did not work either.
I ran reflector, and it is able to expand the protected methods. So I know there has got to be a way. But flattening the heirarchy did not do it.
I have determined that ReflectionPermissions must be used. Now all I have to do is figure out WHERE!
This signature left intentionally blank
|
|
|
|
|
theRealCondor wrote:
Well, I tried this and it did not work either.
Yes, it does, I have a running example. You need to determine what the accessor is, and since you MethodInfo object inherits from MethodBase you can pass each instance to a function that would perform some check like the following (just an example):
private string GetAccessor(MethodBase mb)
{
string a = string.Empty;
if(mb.IsPrivate)
a = a.Length > 0 ? a += " private" : a = "private";
if(mb.IsPublic)
a = a.Length > 0 ? a += " public" : a = "public";
if(mb.IsAbstract)
a = a.Length > 0 ? a += " abstract" : a = "abstract";
if(mb.IsVirtual)
a = a.Length > 0 ? a += " virtual" : a = "static";
if(mb.IsStatic)
a = a.Length > 0 ? a += " static" : a = "static";
if(mb.IsFamily)
a = a.Length > 0 ? a += " protected" : a = "protected";
return a;
}
- Nick Parker My Blog | My Articles
|
|
|
|
|
Nick,
I understand what you are saying.....but I need to get the instances to be able to process them. In this class I have about 50 methods in the namespace and every combination of BindingFlags has returned only 2 methods. Neither of which are the protected methods I want. Also, as I said previously, the docs indicate that it is based on the reflection permissions for the module.
Now maybe you have something set up where you have a higher permission set on your modules(???). But when I do this...
bf = BindingFlags.Public|BindingFlags.Instance|BindingFlags.DeclaredOnly|BindingFlags.NonPublic|BindingFlags.Static
container = Assembly.LoadFile(objectName);
widgetType = container.GetType("myNamespace.Widgets.LayoutWidget");
items = widgetType.GetMethods(bf);
...I am always getting back exactly 2 methods instead of the 50+ protected methods. When I dug into the MSDN docs, it stated that this call will only return public methods unless you have the proper reflection permission. So I dug into that documentation which did not help much at all. I got it to where I am setting my permission to
ReflectionPermissionFlag.MemberAccess and I do a permission.Assert(). But this has not helped me get anything but the two public methods as well.
This signature left intentionally blank
|
|
|
|
|
Since you're OR'ing BindingFlags.DeclaredOnly , inheritted methods will not be included. The other 48+ methods that aren't being listed are not inheritted, are they?
Also, iff you tried to do something that CAS (code access security) wouldn't let you do, it doesn't gracefully fail - it throws an exception. If your code is run locally, then by default you have FullTrust permissions.
I recommend using the permview.exe utility to help see what permission are required, and examine your .NET CAS configuration (either using mscorcfg.msc for the Framework version under which your code is executed, or using the appropriate caspol.exe utility verison). Asserting those permissions won't help (and is actually not what you want to do - read on...) - you need to have them in the first place.
Asserting grants callers of your code a permission that you already have, even if those callers aren't granted that permission. It can be very dangerous. Demand is what you want to do. Asserting the permission in your own code only benefits callers. For example, if the .NET BCL (base class libraries) must check the registry for a settings regardless of what permission you have, they will assert that permission so you can call that method.
CAS can be a little confusing. There's an article here on CodeProject - Understanding .NET Code Access Security[^] - that may be very helpful and more consise than digging through the .NET Framework SDK documentation.
Software Design Engineer
Developer Division Sustained Engineering, Microsoft
My Articles
|
|
|
|
|
Just for interest sake, as you dont mention,
Does it list private and/or internal members? If so, then we have found a .NET reflection bug. I have seen this when trying to read nested protected attribute classes on fields. Sounds very related. Let me no, plz
Cheers
top secret xacc-ide 0.0.1
|
|
|
|