Hi, All,
I have an issue really need help on, Thanks in advance!!!
OS: windows xp
.NET framework v1.1
Enterprise Instrumentation Framework installed
I did the following customization in the event schema project:
Modified the CommonEvent class:
1. added property String ContextKey
2. added property MyExtraInfo ExtraInfo
The MyExtraInfo class:
using System;
using System.Collections.Specialized;
using System.Runtime.Serialization ;
using Microsoft.EnterpriseInstrumentation.Schema;
[Serializable]
[InstrumentationType]
public class MyExtraInfo : ISerializable
{
private NameValueCollection data;
public CLCExtraInfo()
{
data = new NameValueCollection();
}
public CLCExtraInfo(SerializationInfo info,StreamingContext context)
{
data = new NameValueCollection();
System.Runtime.Serialization.SerializationInfoEnumerator enumerator
= info.GetEnumerator();
while (enumerator.MoveNext())
{
data.Add(enumerator.Current.Name,
enumerator.Current.Value.ToString());
}
}
public void Add(string keyName, string keyValue)
{
data.Add(keyName, keyValue);
}
void ISerializable.GetObjectData(SerializationInfo info,
StreamingContext context)
{
if (data.Count == 0) return;
foreach (string key in data.AllKeys)
{
info.AddValue(key, data[key]);
}
}
}
When I raise event with ContextKey and ExtraInfo (added bunch of name-value
pairs) set, from the eventlog, I see the ContextKey has been serialized
correctly
but the ExtraInfo which is a type I defined, serialized as
MyExtraInfo ExtraInfo = {}
which means nothing insidem, Could anyone point out what could be the
problem?
Thanks very much!
John
Barath Vasudevan [MS] - 10 Dec 2003 21:50 GMT
Hi John,
I'm currently working on your issue and will get back to you in a day or
two. Let me know if you have any questions.
Thx
Barath
This posting is provided "As Is" with no warranties, and confers no
rights.Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
--------------------
>From: "John Lee" <john-nospam@pursca.com>
>Subject: Customer Event Schema - Enterprise Instrumentation Framework
[quoted text clipped - 8 lines]
>NNTP-Posting-Host: 63.94.100.67
>Path:
cpmsftngxa07.phx.gbl!cpmsftngxa06.phx.gbl!cpmsftngxa09.phx.gbl!TK2MSFTNGP08.
phx.gbl!tk2msftngp13.phx.gbl
>Xref: cpmsftngxa07.phx.gbl microsoft.public.vsnet.enterprise.tools:1518
>X-Tomcat-NG: microsoft.public.vsnet.enterprise.tools
[quoted text clipped - 69 lines]
>
>John
Mike Hayton [MS] - 11 Dec 2003 05:04 GMT
Hi John,
The reason is that EIF will only output the public properties/fields in the
"InstrumentationType" (i.e. MyExtraInfo in this case)
The type of such properties/fields has to be a primitive (e.g. string, int,
etc) or a type must be marked with "InstrumentationType"
If its not a primitive & its not marked with "InstrumentationType" EIF will
complain when you installutil the schema assembly.
(in this situation you would probably want to use the "[Internal]"
attribute on such a field/property)
So in the case you list below
property MyExtraInfo ExtraInfo
is picked up and serialized out by EIF - its a public property, its type is
marked with InstrumentationType. So far so good.
However, it searches the MyExtraInfo type for public properties/fields and
finds none - so nothing is output.
If you put something like the following into you MyExtraInfo class.
[InstrumentationType]
public struct NameValuePair
{
public string Name;
public string Value;
}
public NameValuePair [] Details
{
get
{
NameValuePair [] array = new NameValuePair[this.data.Count];
int index = 0;
foreach (string key in this.data)
{
NameValuePair nameValuePair = new NameValuePair();
nameValuePair.Name = key;
nameValuePair.Value = this.data[key];
array[index++] = nameValuePair;
}
return array;
}
}
and rebuild and installutil the event schema, you should start to see
something coming through....
you might want to just return an array of string [][] - (I think EIF
handles this?). In this case the code would look something simpler like:
public string [][] Details
{
get
{
string [][] array = new string[this.data.Count][];
int index = 0;
foreach (string key in this.data)
{
array[index++] = new string[] { key, this.data[key]};
}
return array;
}
}
you wouldnt need the additional type.
Hope this helps
Mike
--------------------
| Hi John,
| I'm currently working on your issue and will get back to you in a day or
[quoted text clipped - 79 lines]
| >
| >John

Signature
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
John Lee - 12 Dec 2003 01:21 GMT
Hi, Mike,
Thanks very much!!!
It looks like the EIF did not use Soap or Binary formatter to serialize
Event Schema class, and it might use XmlSerializer or its own serialization
method.
It worked well by define a NameValuePair class marked as serializable and
instrumentationType, and the expose a public property as follows:
public NameValuePair[] Data
{
...
}
then I got the following serialized results:
CLCExtraInfo ExtraInfo = {
NameValuePair[] Data = {
NameValuePair Data[0] = {
String Name = "key1"
String Value = "value1"
}
NameValuePair Data[1] = {
String Name = "key2"
String Value = "value2"
}
}
}
It's not so elegant but it's better than nothing!!! :)
By the way,
1. Struct would not work in this case because when you use installUtil to
install the custom schema into WMI it generate error
2. String[][] does not work either because I got "jagged array is not
supported" error when I use installUtil
Do we have a VB.NET version of the Event Schema to start with?
Best Regards,
John
> Hi John,
>
[quoted text clipped - 155 lines]
> | >
> | >John
"John Eikanger [MSFT]" - 19 Dec 2003 00:39 GMT
Hi, John
Mike will be out of office for the next month. We just noticed your post
or we would have gotten back to you sooner.
Please let me know if you are still there and I will get an escalation
created for you.
Thank you for choosing the MSDN Managed Newsgroups,
John Eikanger
Microsoft Developer Support
This posting is provided ?AS IS? with no warranties, and confers no rights.
--------------------
| From: "John Lee" <john-nospam@pursca.com>
| References: <ebQ58PrvDHA.3116@tk2msftngp13.phx.gbl>
<lHz2qe2vDHA.3136@cpmsftngxa07.phx.gbl>
<mN4YGR6vDHA.3532@cpmsftngxa07.phx.gbl>
| Subject: Re: Customer Event Schema - Enterprise Instrumentation Framework
| Date: Thu, 11 Dec 2003 17:21:39 -0800
[quoted text clipped - 212 lines]
| > Use of included script samples are subject to the terms specified at
| > http://www.microsoft.com/info/cpyright.htm