|
okay i need some help with my Linq to Xml code, i want to check if the new XElement that im about to create has the same XAttribute as an old XElement, if it has the same XAttribute as another XElement then instead of adding a new XElement with same XAttribute i want it to replace the old one.
This is my c# code:
string calendarxml = "C:/Users/Miro/Documents/Visual Studio 2008/Projects/Post-it/Post-it/CalendarXml.xml";
XElement doc = XElement.Load(calendarxml);
XElement root =
new XElement("CalendarNote",
new XAttribute("Date",
monthCalendar1.SelectionStart.ToString("dddd dd MMMM yyyy")),
textBox1.Text);
doc.Add(root);
doc.Save(calendarxml);
and the output in my xmlfile looks like this:
<calendar>
<CalendarNote Date="söndag 17 maj 2009">asdasd</CalendarNote>
<CalendarNote Date="lördag 16 maj 2009">123123</CalendarNote>
<CalendarNote Date="söndag 17 maj 2009">asdad</CalendarNote>
<CalendarNote Date="lördag 16 maj 2009">123123</CalendarNote>
<CalendarNote Date="söndag 17 maj 2009">asdads</CalendarNote>
</calendar>
i dont want to have three söndag 17 maj 2009 and two lördag 16 maj 2009, i want just one, instead of adding a new one with same attribute i want it to replace the old one.
|
|
|
|
|
hello
I ran into this, apparently it has to do with remoting permissioning. I have no idea where to start and my brain is fried... it seems like it happens after I signed my assemblies but since there're many dll's I signed not sure if I want to unsign them to confirm this.
<br />
Server stack trace: <br />
at System.Runtime.Serialization.FormatterServices.GetSafeUninitializedObject(Type type)<br />
at System.Runtime.Serialization.Formatters.Binary.ObjectReader.ParseObject(ParseRecord pr)<br />
at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Parse(ParseRecord pr)<br />
at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.ReadObjectWithMapTyped(BinaryObjectWithMapTyped record)<br />
at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.ReadObjectWithMapTyped(BinaryHeaderEnum binaryHeaderEnum)<br />
at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.Run()<br />
at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler handler, __BinaryParser serParser, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)<br />
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)<br />
at System.Runtime.Remoting.Channels.CoreChannel.DeserializeBinaryRequestMessage(String objectUri, Stream inputStream, Boolean bStrictBinding, TypeFilterLevel securityLevel)<br />
at System.Runtime.Remoting.Channels.BinaryServerFormatterSink.ProcessMessage(IServerChannelSinkStack sinkStack, IMessage requestMsg, ITransportHeaders requestHeaders, Stream requestStream, IMessage& responseMsg, ITransportHeaders& responseHeaders, Stream& responseStream)<br />
<br />
Exception rethrown at [0]: <br />
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)<br />
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)<br />
at Util.Command.CommandRunner.set_Commands(List`1 value)<br />
at RemotingInterfaceInteractiveClient.Program.ProcessCommandFile(RemotingClientSetup& oSetup) in C:\...\RemotingInterfaceInteractiveClient\Program.cs:line 163 {Inner Exception: System.Security.SecurityException: Request failed.<br />
at System.Runtime.Serialization.FormatterServices.nativeGetSafeUninitializedObject(RuntimeType type)<br />
at System.Runtime.Serialization.FormatterServices.GetSafeUninitializedObject(Type type)<br />
The action that failed was:<br />
Demand<br />
The type of the first permission that failed was:<br />
System.Security.PermissionSet<br />
The demand was for:<br />
<PermissionSet class="System.Security.PermissionSet"<br />
version="1"<br />
Unrestricted="true"/><br />
<br />
The only permitted permissions were:<br />
<PermissionSet class="System.Security.PermissionSet"<br />
version="1"><br />
<IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"<br />
version="1"<br />
Flags="SerializationFormatter"/><br />
</PermissionSet><br />
<br />
The method that caused the failure was:<br />
System.Runtime.Remoting.Channels.ServerProcessing ProcessMessage(System.Runtime.Remoting.Channels.IServerChannelSinkStack, System.Runtime.Remoting.Messaging.IMessage, System.Runtime.Remoting.Channels.ITransportHeaders, System.IO.Stream, System.Runtime.Remoting.Messaging.IMessage ByRef, System.Runtime.Remoting.Channels.ITransportHeaders ByRef, System.IO.Stream ByRef)<br />
Any suggestion how to approach this sort of problem?
Many thanks!
dev
|
|
|
|
|
I have created Windows Form application in VS 2008 using C#. In this application, I have created Crystal Report. Now I want to embed flash file (i.e. SWF file) into this Crystal Report.
I do not find any option to add Flash File into Crystal Report. How can I do it?
Please, help if have any idea about it.
Thanks.
|
|
|
|
|
Dear All,
I am working on grid view i wana to assign paging index as like in google page with a constant range like 1 to 25.
Can any one guide me what i have to do for this
Please do replay..
|
|
|
|
|
well you could load all your rows into a datatable or something, then you create a bunch of buttons to act as page numbers, or a drop down list, based on the number of rows in the datatable.
So if you have 128 rows you could do...
int numberOfPages = numRows % 25 == 0 ? numRows / 25 : numRows / 25 + 1;
then on each button click, you load the first 25 result starting at a number obtained by...
int startRowNumber = (pageNumber - 1) * 25;
Alternatively you can get the startRowNumber and search you datasource for each page load. Depending on what your data source is will depend how you could do this. Some databases have functionality to specify a results count and start value. But you will have to look into that yourself
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
I want to close a form after showing another form from this form and other form still shown.
(in general whole application is closed)
ankur bansal
|
|
|
|
|
It depends on what you want, taking in consideration that there is a main form that shouldn't be closed, other forms could be, and you have the option of closing the forms or hiding them, preferrably is to close them of course except the main form which should be just hidden.
Sincerely Samer Abu Rabie
Imagination is more important than knowledge !
|
|
|
|
|
You can use your form as application.
In Program.cs file you can write it one by one.
Application.Run(new Form1());
Application.Run(new Form2());
If you can think then I Can.
|
|
|
|
|
Hi,
I had a small application of BHO using c#.
1. How to know Header Information when a web page is getting loaded on browser (IE)?
2. when we click a link http://mca.gov.in/MinistryWebsite/dca/help/efiling/NewFormsFees.pdf the PDF file is opened in other window (other tab),
how the pdf file is rendered in Internet explorer?
When the PDF file is opened in Ie, the PDF data is obtained packet by packet, How can I know that PDF is fully loaded on browser.
I want this to be done by using BHO as BHO gets injected, it performs the same thing for each and every instance of IE?
|
|
|
|
|
1. I have no idea since I've never written a BHO.
2. The PDF file is rendered by an plugin to Internet Explorer. Perhaps you've heard of Adobe Acrobat Reader??
svt gdwl wrote: When the PDF file is opened in Ie, the PDF data is obtained packet by packet, How can I know that PDF is fully loaded on browser.
The file is downloaded to the Temporary Internet Files folder. You may want to look into the DocumentComplete events. I have no idea if they will suit your needs or not.
|
|
|
|
|
Hi all,
I am transfering a 200mb data from my socket program to the client and i have the following error during execution. I guess it because of the huge data but am not sure in rectifying the issue. I have given the error below
"An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full"
Thanks
Maheshkumar B
|
|
|
|
|
Never seen it before but it sounds like buffer overrrun. Are you using streams so that you only work with small parts of the whole data continuously or attempting to do everything at the end?
Regards,
Rob Philpott.
|
|
|
|
|
Thanks for the Reply Rob
I am new to socket programming
I am trying send all the data in a single iteration.
I need to separate the data in to several segments to make sure the buffer is not full. but don't know how to do it.
|
|
|
|
|
Problem is caused by a recent windows patch. If you remove patch KB948609 the client side deserialization will except large datasets again. Or move to WCF as your transport method.
Read more at: EggHeadCafe[^]
Kind regards,
The only programmers that are better C# programmers, are those who look like this -> |
Programm3r
My Blog: ^_^
|
|
|
|
|
Hello,
Assembly probing - how to instruct runtime to look under bin folder instead of GAC?
According to this article[^], runtime default behavior is to check GAC BEFORE other location.
So the fact that I added probing hint didn't change this (i.e. runtime is still binding to dll in GAC):
<br />
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"><br />
<probing privatePath="bin;bin\Debug;bin\Release;"/><br />
</assemblyBinding><br />
But this is NOT what I need, I actually need it to go bin folder for it?
This may be relevant.[^]
Also how can I check which version is being binded to? I launched "fuslogvw" but it is just sitting there. Nothing shows for some reason... it's giving me headache because (a) dll in GAC no debug information (even under DEBUG build)
(b) nHibernate mapping files loading - my mapping files are in bin folder, not in GAC
Thanks
dev
|
|
|
|
|
AppDomain.CurrentDomain.AssemblyLoad
and
AppDomain.CurrentDomain.AssemblyResolve
You may be able to write some code with those events to accomplish your goals.
|
|
|
|
|
sorry not exactly sure
you're saying i should implement event handlers to assembly loading/probing, set a breakpoint and see where it takes us?
I am suspecting perhaps it has to do with signing or that I've accidentally put one of System.Remoting.xxx dll into GAC (I ran a util which installed my dll's into GAC - which may have incorrectly installed System.Remoting.xxx into GAC ...)
so dead
dev
|
|
|
|
|
When the run time detects it is time to load an assembly it will call that method first allowing you to provide the assembly. You can then load whatever version you wish.
|
|
|
|
|
ah... ok...
i'm starting another test now though. Restore my monday backup and run the test cases again. If that works, it means I didn't screw up my GAC by installing any System.Remoting.XXXX there.
If no, then ...
awe... i cant think straight now all i can do is to watch test cases run after i restore backup my mind is just too fried.
dev
|
|
|
|
|
Especially on Thursdays is a long lunch :p
|
|
|
|
|
good stuff - just ran test cases against MON backup it's okay --- meaning:
(1) I lost up to MONDAY but not more
(2) My machine's GAC is *NOT* the problem
I will give my mind some rest before coming back next WED, then add back what i did last two days, bit by bit
Thanks for your advice though
dev
|
|
|
|
|
hey...
is this what you meant?
<br />
static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)<br />
<br />
43: {<br />
<br />
44: Debug.WriteLine(string.Format("CurrentDomain_AssemblyResolve reports that '{0}' was unresolved.", args.Name));<br />
<br />
45: <br />
<br />
46:
<br />
47: string[] parts = args.Name.Split(',');<br />
<br />
48: if (parts.Length > 0)<br />
<br />
49: {<br />
<br />
50: Assembly assembly = Assembly.LoadFrom(string.Format(@"{0}\{1}.dll", assemblyPath, parts[0].Trim()));<br />
<br />
51: return assembly;<br />
<br />
52: }<br />
<br />
53: <br />
<br />
54: return null;<br />
<br />
55: }<br />
<br />
56: <br />
Thanks!
http://blogs.conchango.com/markmann/archive/2008/09/01/loading-and-resolving-assemblies.aspx[^]
dev
|
|
|
|
|
oh this looks like it...
<br />
Assembly currentDomain_AssemblyResolve(object sender, ResolveEventArgs args)<br />
{<br />
<br />
Assembly MyAssembly, objExecutingAssemblies;<br />
string strTempAssmbPath = "";<br />
<br />
objExecutingAssemblies = Assembly.GetExecutingAssembly();<br />
AssemblyName[] arrReferencedAssmbNames = objExecutingAssemblies.GetReferencedAssemblies();<br />
<br />
foreach (AssemblyName strAssmbName in arrReferencedAssmbNames)<br />
{<br />
if (strAssmbName.FullName.Substring(0, strAssmbName.FullName.IndexOf(",")) == args.Name.Substring(0, args.Name.IndexOf(",")))<br />
{<br />
<strong>strTempAssmbPath = txtAssemblyDir.Text;</strong><br />
if (strTempAssmbPath.EndsWith("\\")) strTempAssmbPath += "\\";<br />
strTempAssmbPath += args.Name.Substring(0, args.Name.IndexOf(",")) + ".dll";<br />
break;<br />
}<br />
<br />
}<br />
MyAssembly = Assembly.LoadFrom(strTempAssmbPath);<br />
<br />
return MyAssembly;<br />
}<br />
http://www.chilkatsoft.com/p/p_502.asp[^]
Thanks for your hint
dev
|
|
|
|
|
Hi,
I am developing a application in which i need to get the list of installted programs on windows server 2003, from add or remove programs. I am using C#. any idea how to do it.
Currently I am having this code:
const string INSTALLED_SOFTWARE = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall";
string[] softwareInstalled;
try
{
regKey = Registry.LocalMachine.OpenSubKey(INSTALLED_SOFTWARE);
softwareInstalled = regKey.GetSubKeyNames();
regKey.Close();
}
From this I am getting complete program list. But I am looking for specifically add/ remove program list.
Thanks in advance,
Priyanka
|
|
|
|
|
Hi,
Read the following article[^], I think it will help.
Kind regards,
The only programmers that are better C# programmers, are those who look like this -> |
Programm3r
My Blog: ^_^
|
|
|
|