[Message Prev][Message
Next][Thread Prev][Thread Next][Message
Index][Thread Index]
Re: Errors using xAPFramework.net 1.2.9.12
On Wed, 26 Oct 2005 17:54:57 -0000, "darrenp_lock"
<darrenlock@xxxxxxx> wrote:
>I have a problem constructing a message using the framework. The code
>is as follows:
>
> Dim message = New xAPMessage
> message.Header = New xAPHeader
>
>When the 2nd line is executed I receive the following exception:
>"An unhandled exception of type 'System.FormatException' occurred
in
>xapmessage.dll Additional information: The Device name cannot contain
>space characters"
As the error suggests, a Device name such as "TestFramework" in
the
Source line "KCSoft.TestFramework.anya" cannot contain space
characters.
I'm going to take a guess that the application you're develping
contains a space in its EXE name e.g. "Test Framework.EXE"?
If that's the case then either:
1. Edit your app.config file and add something like:
<appSettings>
<add key="xAPHeaderSourceDevice"
value="TestFramework" />
</appSettings>
Or 2. Somewhere very early on in the lifetime of your application add
the VB.NET equivalent of:
xAPConfig.HeaderSourceDevice = "TestFramework";
An explanation is now in order!
When you instantiate an instance of xAPHeader xFx fills in all the
mandatory parameters for you e.g. Hop, Version, Source, Class, etc.
xFx attempts to make it as easy as possible to form a message although
it doesn't always succeed!
Given that it doesn't know what values you want for things like UID it
can use some reasonable defaults. I think Class just defaults to
"Class.Type" until you tell it something differently.
But the Source address is pulled from a few components. Since it
contains the values for Vendor, Device and Instance, it defaults each
of these from different places.
Vendor is, I'm afraid, defaulted to "KCSoft", xFx's native Vendor
:)
Device comes from the name of the *entry* Assembly ie the EXE name. So
if you include space characters in this it'll barf as it has done I
expect. This is an interesting buglette that I've just changed so that
space characters get substituted for underscores. I tend not to write
applications with space characters in their names hence why I've never
spotted this before!
Instance comes from the name of your machine.
You can either customise these values through the app.config file as
shown. There are a ton of parameters you can configure, all detailed
in the "Sample app.config" file somewhere in the xFx SDK. But the
ones
you want are:
<!-- Configures a header source value with this Vendor name if not
otherwise supplied in the code -->
<add key="xAPHeaderSourceVendor" value="KCSoft"
/>
<!-- Configures a header source value with this Device name if not
otherwise supplied in the code -->
<add key="xAPHeaderSourceDevice" value="Application"
/>
<!-- Configures a header source value with this Instance if not
otherwise supplied in the code -->
<!-- Note that the Instance value can include subinstances and
subaddresses to any required depth -->
<add key="xAPHeaderSourceInstance" value =
"Instance" />
<!-- Configures the subinstance value to be appended to a header source
address -->
<!-- e.g. if an Instance of "Server" is used, and a
subinstance value of "Line1" then
"KCSoft.Meteor.Server.Line1" results.
But if "Server.Line1" is specified as the Instance value, a
Subinstance value of "Test" would result in
"KCSoft.Meteor.Server.Line1.Test" -->
<add key="xAPHeaderSourceSubinstance" value =
"Subinstance" />
This means that anybody can adjust your application parameters. So I
introduced option (2) above so that you can hard-code them on an
app-by-app basis. All my own xAPplications have these lines early on:
// Fix the Vendor & Device values to use wherever the values would
otherwise be retrieved from the app.config file
xAPConfig.HeaderSourceVendor = xAPHeaderSource.DefaultSourceVendor;
xAPConfig.HeaderSourceDevice = "Hub";
...where "Hub" is configurable according to the name I assign to
the xAPplication.
The user is free to adjust the Instance name to their own
requirements, but the machine name almost always sufficies here at
least.
If that doesn't fix it I'll keep looking. Let me know,
S
--
Stuart Booth <stuart@xxxxxxx>
xAPFramework.NET - a xAP software development framework for .NET
http://www.xapautomation.org/
http://www.xapframework.net/
xAP_Development Main Index |
xAP_Development Thread Index |
xAP_Development Home |
Archives Home
|