|
I don't suppose you'd want something like this...
[GroupOfAttribute(
"<OneAttribute Num=\"001\" Text=\"sh\" When=\"2007-11-08\" />"
,
"<OneAttribute Num=\"002\" Text=\"sh\" When=\"2007-11-08\" />"
,
"<OneAttribute Num=\"003\" Text=\"sh\" When=\"2007-11-08\" />"
)]
Ugly ugly ugly... error prone and not very typesafe... but it works!
|
|
|
|
|
Hi
I saw from your example that you are using framework 3.0 or above
Try using the follwoing code
List<BugFixAttribute> lst = new List<BugFixAttribute>((IEnumerable<BugFixAttribute> )inf.GetCustomAttributes(typeof(BugFixAttribute), false));
lst.Sort((a, b) => a.BugID < b.BugID ? -1 : 1);
|
|
|
|
|
hi
i use Sql server 2005 reporting Service in my app in local processing mode, in report designer i add a textBox and i want send value from my csharp code to textBox of report, i use this code :
try
{
this.v_customerOrderCountTableAdapter.Fill(this.NorthwindDataSet.v_customerOrderCount);
Microsoft.Reporting.WinForms.ReportParameter rp = new Microsoft.Reporting.WinForms.ReportParameter("textbox5", "Param From Code");
this.reportViewer1.LocalReport.SetParameters(new Microsoft.Reporting.WinForms.ReportParameter[] { rp });
this.reportViewer1.RefreshReport();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
but the following error shown me :
An error occurred during local report processing.
where does my problem and how to send parameters deom my code to report ?
thanks
|
|
|
|
|
Did you add the parameter to the report itself? If the report has parameter called paramater1 and you want to set its value to myvalue then you should do it like this:
<br />
Microsoft.Reporting.WinForms.ReportParameter rp = new Microsoft.Reporting.WinForms.ReportParameter("paramater1", "myvalue");<br />
this.reportViewer1.LocalReport.SetParameters(new Microsoft.Reporting.WinForms.ReportParameter[] { rp });<br />
|
|
|
|
|
i add in a textBox named 'textBox5' to my report in report designer and wrote your code (that like my code), but the above error has shown me.
|
|
|
|
|
It seems that you haven't added the parameter to the report itself
|
|
|
|
|
Hello all,
I have a curious problem relating to XML deserialisation where the deserialiser allows malformed XML to pass through without issue. This needs some further information, so without further ado:
I have the following simple schema:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="TestSchema">
<xs:complexType>
<xs:sequence>
<xs:element name="Widgets" type="xs:string" nillable="false"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
From this I have created .NET 2 c# classes using the XSD tool, this result in the following class
using System.Xml.Serialization;
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.42")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)]
[System.Xml.Serialization.XmlRootAttribute(Namespace="", IsNullable=false)]
public partial class TestSchema {
private string widgetsField;
public string Widgets {
get {
return this.widgetsField;
}
set {
this.widgetsField = value;
}
}
}
This is then added to a simple test project that looks like this:
static void Main(string[] args)
{
string rawXml = "<TestSchema>";
rawXml += "<Widgets>A value for widgets</Widgets>";
rawXml += "<LaLa>An element that doesnt exist in the schema</LaLa>";
rawXml += "</TestSchema>";
byte[] data = System.Text.Encoding.ASCII.GetBytes(rawXml);
MemoryStream fs = new MemoryStream(data);
TextReader reader = new StreamReader(fs);
XmlSerializer ser = new XmlSerializer(typeof(TestSchema));
TestSchema obj = (TestSchema)ser.Deserialize(reader);
reader.Close();
Console.WriteLine(obj.GetHashCode());
Console.ReadLine();
}
Now all this works, however I wouldn't expect it to! The more eagled eyed will have noticed the following line in the code above:
rawXml += "<LaLa>An element that doesnt exist in the schema</LaLa>";
When the deserialiser is processing the XML string, it seems that any elements that are not in the C# schema class are simply ignored. So the first question is, does anybody know of a way to run the deserialiser in "strict" mode, so that if an unknown element is present then an exception occurs.
When testing different scenarios I also discovered that I could remove a nillable false element and still deserialise, which resulted in the object value being, obviously, null. For example :
string rawXml = "<TestSchema>";
rawXml += "</TestSchema>";
or
string rawXml = "<TestSchema>";
rawXml += "<LaLa>Hold on whats this an element that doesnt exist in the schema</LaLa>";
rawXml += "</TestSchema>";
So the second questions is, is there any way to run the deserialiser in "strict" mode where if a mandatory/nillable false element is not found and exception occurs.
An immediately obvious solution to this problem is to pass the XML through a validator first and then perform the deserialisation. While this will work, in the real world the application is processing alot of XML data and having to validate every one will add to processing time. I would prefer to only validate if a deserialisation exception occurs.
-- modified at 10:31 Thursday 8th November, 2007
|
|
|
|
|
It would seem I have found the solution, a tweak to the code above and malformed XML is no longer allowed:
static void Main(string[] args)
{
string rawXml = "<TestSchema>";
rawXml += "<Widgets>A value for widgets</Widgets>";
rawXml += "<LaLa>Hold on whats this an element that doesnt exist in the schema</LaLa>";
rawXml += "</TestSchema>";
XmlSerializer s = new XmlSerializer(typeof(TestSchema));
byte[] buffer = ASCIIEncoding.UTF8.GetBytes(rawXml);
MemoryStream ms = new MemoryStream(buffer);
XmlReader reader = new XmlTextReader(ms);
XmlDeserializationEvents deserializationEvents = new XmlDeserializationEvents();
deserializationEvents.OnUnknownAttribute = new XmlAttributeEventHandler(UnknownAttributeEventHandler);
deserializationEvents.OnUnknownElement = new XmlElementEventHandler(UnknownElementEventHandler);
deserializationEvents.OnUnknownNode = new XmlNodeEventHandler(UnknownNodeEventHandler);
deserializationEvents.OnUnreferencedObject = new UnreferencedObjectEventHandler(UnreferencedObjEventHandler);
TestSchema obj = (TestSchema)s.Deserialize(reader, deserializationEvents);
reader.Close();
Console.WriteLine(obj.GetHashCode());
Console.ReadLine();
}
private static void UnknownAttributeEventHandler(object sender, XmlAttributeEventArgs e)
{
}
private static void UnknownElementEventHandler(object sender, XmlElementEventArgs e)
{
}
private static void UnknownNodeEventHandler(object sender, XmlNodeEventArgs e)
{
}
private static void UnreferencedObjEventHandler(object sender, UnreferencedObjectEventArgs e)
{
}
As you can see in the code above, the XmlSerializer.Deserialize can also take an instance of XmlDeserializationEvents. If this is setup and passed in these events are created and from there I can handle the error condition.
|
|
|
|
|
Good to know... thanks for posting that!
|
|
|
|
|
Since posting the original solution I have found that you can also set these event directly on the XmlSerializer
XmlSerializer xmlSerializer = new XmlSerializer(objectType);
xmlSerializer.UnknownAttribute += new XmlAttributeEventHandler(xmlSerializer_UnknownAttribute);
xmlSerializer.UnknownElement += new XmlElementEventHandler(xmlSerializer_UnknownElement);
xmlSerializer.UnknownNode += new XmlNodeEventHandler(xmlSerializer_UnknownNode);
xmlSerializer.UnreferencedObject += new UnreferencedObjectEventHandler(xmlSerializer_UnreferencedObject);
From a functionality point of view I don't suppose it makes any difference at all, however IMHO this method is neater.
|
|
|
|
|
hello,
un have 2 application and i send messages between them using named pipes technologie;
i send 2 messages , the first for showing the application and the second for hiding it;
the probleme is before sending the messages i have to know the state of application (show/hide).
how can i know the state of my second application?
|
|
|
|
|
You'll need a method that queries the state of the second application.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
whitch method do you talking about? i can figure out
please help
|
|
|
|
|
A method which you have to write in order to figure out the state of the application !
AliAmjad(MCP)
First make it Run THEN make it Run Fast.
|
|
|
|
|
i m so sorry, but i dont understand what do you mean,
i want to know can i know the state of a dialog or application (hide/show) ?
if yes , how?
thanks
|
|
|
|
|
This is easy. Create a method that checks if the form is visible or not.
(Hint: use the Visible property)
Kristian Sixhoej
"Any fool can learn from his own mistakes, but a wise man learns from mistakes of others"
|
|
|
|
|
Check to see if the form is visible.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
i want to know if is visible from another application not the same application
i hope that now that s is more clear
|
|
|
|
|
Morad SAJID wrote: i want to know if is visible from another application not the same application
i hope that now that s is more clear
How can I put this simply? If you want to know if application B is visible or not, then application A is going to have to query it and ask it if it is visible or not. Hence, application B will have to provide this information. That's what we've been telling you all along. There's no easy way for the first application to know this - it's the responsibility of the second app to tell it.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
yes thank you
i have an idéa but i don't know if it will be works;
i ll change the process name of the application A, the application B will looking for the first name of application A , when it will not find it it will know that my application is hided,
but how to change the processname of my application;
thakks again
|
|
|
|
|
I would have the application that shows/hides create a named Mutex when it is visible. It can release the Mutex when it gets hidden.
The calling app can try and create the same named Mutex and if it fails, it knows the application is visible. If it succeeds, it releases the Mutex and knows that the application is hidden.
|
|
|
|
|
Hi Guys. I need a bit of help. I want to put a sql server connection together but don;t know how. I have only previously worked with .MDF files but now want to put a connection together to a SQL server. The details of the server is as such.
Server - JBSQL1\DEV1
DataBase - CSIS
How do I use this to create a sql server connection? Or do you guys know of any documentation that states clearly how to do this as I have looked, googled and nothing seems clear and straight forward.
Any help would be greatly appreciated.
|
|
|
|
|
Kwagga wrote: I want to put a sql server connection together but don;t know how.
Here[^]
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
i got some error while connecting the server database(sqlserver in DATABASE sever) ....System.Data.SqlClient.SqlException: An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
when i put the code in server
but i can connect it in client side(using .net 2005 development platform)
i just use the code
SqlConnection con = new SqlConnection("Data Source=server ip;initial catalog=database name;uid=userid;pwd=password");
sqlCommand cmd = new SqlCommand();
cmd.CommandText = "select * from StLogin";
cmd.Connection = con;
SqlDataReader dr;
con.Open();
dr = cmd.ExecuteReader();
while (dr.Read() != false)
{
DropDownList1.Items.Add(dr[1].ToString());
}
|
|
|
|
|
I'm sick of answering this one for people. Here[^], help yourself.
Deja View - the feeling that you've seen this post before.
|
|
|
|