|
Just a quick check, but your namespace that the class sits in is definately config right?
Eg, the code should look something like this:
using System;
using System.Configuration;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace config
{
public class SomeSettings : ConfigurationSection
{
private SomeSettings() { }
[ConfigurationProperty("FillColor", DefaultValue = "Cyan")]
public System.Drawing.Color FillColor
{
get { return (System.Drawing.Color)this["FillColor"]; }
set { this["FillColor"] = value; }
}
[ConfigurationProperty("TextSize", DefaultValue = "8.5")]
public float TextSize
{
get { return (float)this["TextSize"]; }
set { this["TextSize"] = value; }
}
[ConfigurationProperty("FillOpacity", DefaultValue = "40")]
public byte FillOpacity
{
get { return (byte)this["FillOpacity"]; }
set { this["FillOpacity"] = value; }
}
}
}
|
|
|
|
|
I solved it definetly... i not defined any namespace, so the problem was in App.config...
<?xml version="1.0" encoding="utf-8" ?><br />
<configuration><br />
<configSections><br />
<section name="SomeSettings" type="SomeSettings, config" /><br />
</configSections><br />
<SomeSettings FillColor="LightBlue" TextSize="9.5" FillOpacity="50" /><br />
</configuration>
And all works good
|
|
|
|
|
|
Hi.
I'm having a problem and cannot find the solution. trust me, i've read lots on msdn and google'd, in the wrong places obviously but i hope someone here can help me.
I'm porting an application to compact framework 3 and to reduce client side load i created a webservice for the BL (also, else i would have to copy all code and compile to CF since i cant use "regular" dll's in CF)
this webservice exposes some custom classes and a couple of methods. a simple example would be
(in webservice)
public enum ToStringType {
FirstName,
LastName
}
public class person
{
public string firstname {get;set;}
public string lastname {get;set;}
public ToStringType stringtype {get;set;}
public person(){
stringtype = ToStringType.FirstName ;
}
public override ToString(){
public override string ToString()
{
string tostr = string.Empty;
switch (stringtype )
{
case ToStringType.FirstName :
tostr = FirstName;
break;
case ToStringType.LastName:
tostr = LastName;
break;
}
return tostr;
}
and the ws has a method returning person[]
on the client. when i run the method and get a list of persons
first of all:
myperson.ToString() returns the object class name. not first/last-name
so i add a method:
tostr (){
...
}
with the logic in tostring(),
this works. returns firstname. but
if i (on the client) myperson.stringtype =ToStringType.LastName;
and debug the application, i see that myperson.stringtype IS ToStringType.LastName
but the method returns firstname.
i would really get the tostring to work since i'm adding the person[] to a combobox and i prefer not to use datasource/bindings. (tried those to. same problem, Displaymember has no effect)
how come this split personality disorder in my classes, and why does ToString return the class name instead of my overloaded ToString method?
I hope someone can help me
regards Tomas
There is no spoon
modified on Tuesday, June 30, 2009 10:54 AM
|
|
|
|
|
Why didn't you make lastName public like firstName?
|
|
|
|
|
Edited, Thanks for noticing! allthough this was just an example and not the actual code, else the post would have been very very long
If it' stuck, DO NOT pull harder!
|
|
|
|
|
Maybe the StringType is not serialized correctly. I think you have to think about, how to serialise this type...
|
|
|
|
|
I tried changing StringType to int. did nothing. This confuses me a little.
The properties of the object can be modified and keeps their state on the client. but all changes
are lost on the server. since it is stateless one would think that the "original" values also
would be lost, and why isnt the client object values passed to the server for method invocation.
thank god for Apress Books and vacation coming up
Anyway, i solved this by having a local class with the same properties and my custom ToString.
If it' stuck, DO NOT pull harder!
|
|
|
|
|
Just wondering as rxMessage is looking at the 3rd byte not the second am I right putting :
switch (rxMessage[2])
{
case 0x56: // "V" Version Number Request
if (rxMessage.Length == 3)
{
rxCommmandType = commandType.VersionNumRequest;
}
else
{
throw new IndexOutOfRangeException("Inavlid data entered, "
+ "Incorect number of bytes for a display update");
}
break;
|
|
|
|
|
I don't quite know what you are trying to do but one thing that stands out is you are checking to see if the array length is big enough after you access the data. If you want to check if it is available to access then do it before the switch.
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
Ah im just using it to check that i have recieved the correct number of bytes.
If there are more than three bytes in the recieved array then something is wrong throwing an exception.
In other words checking nothing follows the Version number request
|
|
|
|
|
switch (rxMessage[2]) <- change to rxMessage[1] since arrays starts at 0.
rgds Tomas
If it' stuck, DO NOT pull harder!
|
|
|
|
|
byte 0 and one are filled i didnt add this code because it would have crowded the message
<code> // COMMAND HEADER
if (rxMessage[0] != (byte)'J')
{
throw new InvalidDataException("Error: Invalid Command Header found");
}
// MCU TYPE
if (rxMessage[1] != (byte)DEVICE_ID)
{
throw new InvalidDataException("Error: Invalid Device ID");
}
|
|
|
|
|
Ok. i cant say i really understand your question, but rxMessage[2] is the 3'rd byte if that's what you're asking. MCU's are cool btw. i use AVR's alot
If it' stuck, DO NOT pull harder!
|
|
|
|
|
thats kwl thanx. The question was just to check that if i was in array[2] it would be containing three values.
So array.length should equal three or it is invalid so sure its right
|
|
|
|
|
just because you are accessing index 2 of the array it does not mean the length is three. If you can access index 2 without an array then there are at least 3 values.
what you should do is first check the length...
if(array.Length != 3)
then do your switch... I assume that index 3 tells what type of request it is and should always be present?
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
I am using a GridView on a page that will need to display data based on either a URL passed in with a QueryString OR fields passed from a form. This may return 50-500 records or so based on the state etc... If this is too many, (and only if this is too many) the user will be able to filter based on the occupation. I can get it to filter on query string AND state at the same time but not or sadly. I want it to default to all occupations after pulling from the DB based on state, (I tried setting the default value for occupation to -1) and then, the user can use the dropdown control to filter it more.
<asp:dropdownlist id="ddlCategories" runat="server" appenddatabounditems="True" autopostback="True"
datasourceid="sdsCategories" datatextfield="Occupation" datavaluefield="Occupation">
<asp:listitem text="All Categories" value="-1">
</asp:listitem>
</asp:dropdownlist>
<asp:sqldatasource id="sdsCategories" runat="server" connectionstring="<%$ ConnectionStrings:eventsConnectionString1 %>"
selectcommand="SELECT [Occupation] FROM [Events]" ProviderName="<%$ ConnectionStrings:eventsConnectionString1.ProviderName %>">
</asp:sqldatasource>
<asp:gridview id="gvProducts" runat="server" datasourceid="sdsProducts" style="margin-top: 12px;" AllowSorting="True" AutoGenerateColumns="False">
<columns>
<asp:BoundField DataField="EventTitle" HeaderText="EventTitle" SortExpression="EventTitle" />
<asp:BoundField DataField="EventEndDate" HeaderText="EventEndDate" SortExpression="EventEndDate" DataFormatString="{0:MM/dd/yyyy}" />
<asp:BoundField DataField="EventStartDate" HeaderText="EventStartDate" SortExpression="EventStartDate" DataFormatString="{0:MM/dd/yyyy}" />
<asp:BoundField DataField="EventCity" HeaderText="EventCity" SortExpression="EventCity" />
<asp:BoundField DataField="EventState" HeaderText="EventState" SortExpression="EventState" />
<asp:BoundField DataField="Occupation" HeaderText="Occupation" SortExpression="Occupation" />
</columns>
</asp:gridview>
<asp:sqldatasource id="sdsProducts" runat="server" connectionstring="<%$ ConnectionStrings:eventsConnectionString2 %>"
selectcommand="SELECT [EventTitle], [EventEndDate], [EventStartDate], [EventCity], [EventState], [Occupation] FROM [Events] WHERE ([EventState] = ?)" ProviderName="<%$ ConnectionStrings:eventsConnectionString2.ProviderName %>">
<SelectParameters>
<asp:QueryStringParameter DefaultValue="PA" Name="EventState" QueryStringField="ID"
Type="String" />
</SelectParameters>
</asp:sqldatasource>
|
|
|
|
|
Hi all
maybe you can help me a little bit with COM component developed in C#.
I created one C# COM component to provide Excel with some functionality I needeed.
Everything was fine until I did some change to the assembly.
In the new version I did the following:
-I used the same GUID of the old version
-I used using the same strong key name of the old version
- I changed the Assembly version to 1.0.0.0 to 1.0.0.1.
- I registered the assebly in the global assembly cache with gacutil.
Since then Excel is not able to work anymore with this Com and doesn't recognize the library classes.
I tryed to cleanup of my system so I did:
-removal of the library from the GAC
-removal of the typelib
-reinstall of everything from scratch
at the end nothing improved!
What can I do to a perfect clean up of my system?
Some tool or some registry key or value to see?
Thanks in advance
ManuStone
|
|
|
|
|
On form load event i am loading dt Datatable obj from DB.
Setting Listbox control dataSource to dt, and respective display member, value member property. But its taking almost 2 sec,
If i do same for combobox control it takes hardly .1 sec
Why this behavior?
|
|
|
|
|
well it might help to see the code you have used for both methods.
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
musefan wrote: well it might help to see the code you have used for both method
for combobox
Datatable dt = getTable();
cmb.DataSource = dt;
cmb.DisplayMember = "Name";
cmb.ValueMember = "Level";
for listbox
Datatable dt = getTable();
lst.DataSource = dt;
lst.DisplayMember = "Name";
lst.ValueMember = "Level";
On formLoad event.
this code i used, for cmb its fast, but for listbox its slow,
I am wondering why.........??
i am using c#. vs2003
regards,
|
|
|
|
|
Sorry, can't really offer a good answer.
To me it looks like you can't really do anything to help it yourself. I'm thinking maybe the comboBox and listBox handle DataSources differently and that is causing the delay - but I don't know that for sure.
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
I have a C function of format:
func1(double param[], int size);
This function is called from C# code the following syntax:
[DllImport("first.dll", EntryPoint = "func1", CallingConvention = CallingConvention.StdCall)]
public static extern int func1(ref double param[], int size);
The function 'func1' takes two parameters: the array in which values should be filled up from C dll and 'size' which tells the number of values to fill in the array.
Now if the param[] array is declared as param[] = new double[5]; and the 'size' parameter is given as 10, still the function passes.
Wherase the same scenario in direct C application, gives error saying "Array size(i.e. 5) is lesser than the number of values to fill(i.e. 10)".
I am not able to reproduce the same behavior in .Net. Can anybody help me with it?
|
|
|
|
|
My guess (I haven't checked) is that the number of bits used in C for the double may be 32, but in C# it's 64.
Hmmm, it appears that they are both 8 bytes (64 bit)
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
modified on Tuesday, June 30, 2009 9:36 AM
|
|
|
|
|
ok..how to ensure that both the sizes are the same..i mean if i declare array of size 5 (5 x 8 = 40bytes) should be the same in C# also.
|
|
|
|