-
Writing namespace to an XML stream
Date: 02/11/09
Keywords: html, xml
I'm trying to write XHTML to an XmlWriter. I'm having trouble generating the standard line:
http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
With "writer" as my XmlWriter I have
writer.WriteStartElement("html");
writer.WriteAttributeString("xmlns", "http://www.w3.org/1999/xhtml");
writer.WriteAttributeString("lang", "en");
writer.WriteAttributeString("xml:lang", "en");
but writer.WriteAttributeString("xmlns", "http://www.w3.org/1999/xhtml") generates an XmlException: "The prefix '' cannot be redefined from '' to 'http://www.w3.org/1999/xhtml' within the same start element tag."
What am I missing? How do I get that namespace defined?
TIA.
Source: http://community.livejournal.com/csharp/101629.html
-
Writing namespace to an XML stream
Date: 02/11/09
Keywords: html, xml
I'm trying to write XHTML to an XmlWriter. I'm having trouble generating the standard line:
http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
With "writer" as my XmlWriter I have
writer.WriteStartElement("html");
writer.WriteAttributeString("xmlns", "http://www.w3.org/1999/xhtml");
writer.WriteAttributeString("lang", "en");
writer.WriteAttributeString("xml:lang", "en");
but writer.WriteAttributeString("xmlns", "http://www.w3.org/1999/xhtml") generates an XmlException: "The prefix '' cannot be redefined from '' to 'http://www.w3.org/1999/xhtml' within the same start element tag."
What am I missing? How do I get that namespace defined?
TIA.
Source: http://csharp.livejournal.com/101629.html
-
Writing namespace to an XML stream
Date: 02/11/09
Keywords: html, xml
I'm trying to write XHTML to an XmlWriter. I'm having trouble generating the standard line:
http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
With "writer" as my XmlWriter I have
writer.WriteStartElement("html");
writer.WriteAttributeString("xmlns", "http://www.w3.org/1999/xhtml");
writer.WriteAttributeString("lang", "en");
writer.WriteAttributeString("xml:lang", "en");
but writer.WriteAttributeString("xmlns", "http://www.w3.org/1999/xhtml") generates an XmlException: "The prefix '' cannot be redefined from '' to 'http://www.w3.org/1999/xhtml' within the same start element tag."
What am I missing? How do I get that namespace defined?
TIA.
Source: https://csharp.livejournal.com/101629.html
-
add refrence on pre-build
Date: 02/06/09
Keywords: sql
Hello,
First of all, please excuse me for my english.
I have VS2005 Pro. Is there any simple way to programmatically add reference to project on pre-build?
I have a problem with SqlCe reference and bad-known "ProjectAssemblies" folder. So all I need is to add reference before build and remove it after the build. At the moment I'm doing it manually.
May be some VS macro? If not, then may be it could be done by writing a program which will edit solution file before building?
Thanks in advance.
Source: http://community.livejournal.com/csharp/100958.html
-
Enumerate COM port devices
Date: 02/06/09
Keywords: no keywords
Hi,
I am looking for an easy way to enumerate COM port devices (Devices that I see in Windows Device Manager in Ports section). What I found so far is how to get all available com ports, but it doesn't provide any device information.
Thanks.
Source: http://community.livejournal.com/csharp/100411.html
-
a couple of C# questions
Date: 02/02/09
Keywords: java
Are there good non-MS on-line C# language references that you like?
Is there a Java like syntax for implements in C#. I have a class that I want to inherit from the base class and I want it to implement an interface as well.
thanks
Source: http://community.livejournal.com/csharp/100198.html
-
Picturebox with Zoom?
Date: 01/18/09
Keywords: no keywords
I'm working on a specialized image viewer. I need to allow viewers to zoom in and then pan around the image. The stock PictureBox control doesn't seem to support doing this. Most ideally, I need to do this with a vector image. I'm starting with PDF but can convert to pretty much anything; WMF, EPS, whatever.
Any ideas on where to find a component or assembly that'll do this? I've found plenty, but they are multiple hundreds of dollars and are oriented at those needing to do robust image processing, which I don't; just viewing.
Thanks...
Source: http://community.livejournal.com/csharp/100028.html
-
New Connection button causes Choose Data Source to shut down
Date: 12/17/08
Keywords: database
Okay, this is odd. Visual C# 2008 Express Edition on XPSP3.
I create a new form and drag a DataGridView onto it. Expand the little arrow to get the DataGridViewTasks dialog. Expand "Choose data source." One data source I have already created in this project is listed. But I need another one, so I click "Add Project Data Source...". Select "Database" from Choose Data Source Type and hit Next. Up comes the Choose Your Data Connection dialog box. The only data connection listed is Northwind.sdf (which is not the data connection I've already created and that is showing in the previous box). I click the "New Connection..." button and instead of getting the New Connection dialog, the Data Source Configuration Wizard closes and I'm back out at the DataGridViewTasks dialog.
This started happening last night. Before that, I was able to create data sources in this project without a problem. I have rebooted the computer multiple times since it started with no effect at all.
Anyone seen anything like this before? Thanks.
Source: http://community.livejournal.com/csharp/99749.html
-
static data
Date: 12/17/08
Keywords: database
I'm working on a project idea that involves creating an army builder application of sorts. I essentially want to build and manage a database of my collection of figures. The catch is that I want this database to build off of a "static database" of the figures available for the game. This "static database" also needs to be able to be updated when new figures are released.
So my question is this... What is the best way to build this "static database"?
Source: http://community.livejournal.com/csharp/99580.html
-
FaultImportOptions?
Date: 12/04/08
Keywords: web, microsoft, google
I have just created web service in VS2008. I then created a project to act as a client for this service and tried to import a Service Reference using VS2008. I am getting the following error:
---------------------------
Microsoft Visual Studio
---------------------------
Failed to add Service Reference 'ServiceReference1.Reference'.
Error:Could not load type 'System.ServiceModel.FaultImportOptions' from assembly 'System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
Please use Error List window to view the full error message.
---------------------------
OK
---------------------------
A Google search for FaultImportOptions brings up an MSDN page in Portugese, but nothing else. Browsing the System.ServiceModel assembly reveals no FaultImportOptions class or property.
Any ideas?
Source: http://community.livejournal.com/csharp/99117.html
-
Visual Studio && Design Patterns
Date: 11/25/08
Keywords: no keywords
Several years ago (i.e. somewhere in the 1990's), I found a 'plugin' for the JBuilder IDE, that provided a big library of design patterns. You could page through the patterns (with UML class diagrams of the pattern), or you could search for a pattern. Then, with just a few clicks, you could add the pattern to your project.
I miss something like that today. Does anyone know, if there exists such an add-in for the Visual Studio? It doesn't matter if it is payware, as long as there's an evaluation version.
Source: http://community.livejournal.com/csharp/98946.html
-
Reference Accessor
Date: 10/10/08
Keywords: no keywords
Hello guys. Do any of you know how get a property accessor return a reference. I'm sure it can be done, because the framework does it.
Here's an example :
public class Upper {
public struct SInner {
private string m_str;
public string str {
get { return m_str; }
set { m_str = value; }
}
}
private SInner m_Inner = new Inner();
public SInner Inner {
get { return m_Inner; }
}
public void func() {
Inner.str = "value";
}
}
The assignment in func() causes a compile error. This is because i need a reference to m_Inner to be returned, not a copy of the value that simply resets the previous value.
And, yes, there is a reason for it. I know the example seems unnecessarily complex, but it's being dumbed down.
Thanks for any help.
EDIT:
Nevermind, I figured it out. Since Inner was a struct, it was a ValueType. Thus, Inner.str was a value (sort of.) I changed Inner to be a class, and that allowed forced it to be returned by reference.
If that's confusing, just comment. I'll explain it better.
Source: http://community.livejournal.com/csharp/98794.html
-
Accessing an XML-RPC service
Date: 08/11/08
Keywords: xml, yahoo
I'm trying to access an XML-RPC service from C# that I'm building. I've had absolutely no response from my message on the XML-RPC.net YahooGroup, so I started looking at the only other .Net XML-RPC class library out there: XmlRpcCS, which is only confusing me further.
The cause of my problems appears to be that XML-RPC.Net seems to require all its proxy objects to be structs. I, however, would like to use class objects, so I can add other functionality into the classes (constructors, the ability to have properties that are masked from the XML-RPC output and so on).
Now if this were XML serialisation, I would use the attributes that control XML serialisation, such as [XmlIgnore]
. Without rewriting half of the class library, though (which would seem to defeat the purpose of using it!), I can't do something like that.
Does anyone here have any experience of using an XML-RPC library for .Net?
(Cross-posted to ms_dot_net.)
Source: http://community.livejournal.com/csharp/97906.html
-
Managed DirectX
Date: 07/18/08
Keywords: technology, microsoft
Hello!
I use Managed Direct 3D for my graphic engine. But Microsoft will turn off support of this technology. Which technology you advice to me? XNA or something else?
Source: http://community.livejournal.com/csharp/97171.html
-
appilcation settings - change directory path
Date: 07/16/08
Keywords: no keywords
Hello,
sorry for my english :)
I'm using Settings tab of project properties (windows application) for creating user settings. But user settings are written into Documents and settings\userId\Local Settings\Application data\appName\appName_blahblahblah\1.0.0.0\..
I want them to be written into file which is located in program directory. Are there any opportunity to do it by changing some settings in VS or small code changes, or it will be easier to write my own settings manager?
Source: http://community.livejournal.com/csharp/96656.html
-
Saving variables between sessions
Date: 06/27/08
Keywords: no keywords
In short: How do I save variables between sessions?
In long: I have several C# books, but they only briefly touch on the subject, or delve into databasing, which isn't really what I need. I've skirted by so far by so far by working mainly in projects that don't require the carrying over of settings. I'm mostly looking for an online resource that will teach the concept, not so much just a "do this" sort of deal.
Thanks for any help you can offer!
Source: http://community.livejournal.com/csharp/96308.html
-
Vista/2k3 C# Packet Capturing
Date: 06/26/08
Keywords: no keywords
I am trying to find some relatively simple C# packet capture code for capturing incoming/outgoing packets on a single host running Vista and/or Windows 2003 (though it has to work on XP as well).
I had a very robust RawSocket implementation that did everything I needed very nicely, but Vista broke it (it now only captures incoming packets).
I don't mind having to use WinPCap, but even so, all of the C# WinPCap wrappers I've tried have failed miserably attempting to discover NICs in Vista.
If anyone has any information or a link to any information on this topic, I'd appreciate it a great deal.
The final alternative would be to wrap WinPCap into C# myself, but I don't want to reinvent the wheel -- it's already been done. And I'm starting to tire of P/Invokes in this particular application.
Any help appreciated.
Source: http://community.livejournal.com/csharp/96174.html
-
BackgroundWorker
Date: 03/15/08
Keywords: no keywords
I'm playing around with the BackgroundWorker class. Since I've never used it before I was hoping to get some critique. The code works fine but it's probably not using best practices (throughout). I'm using a form with a listbox, button, and timer. Please assume that 'Files' will never contain duplicate names. I don't think any lock() blocks are necessary but I might be wrong.
using System;
using System.Collections;
using System.ComponentModel;
using System.Threading;
using System.Windows.Forms;
namespace ThreadTest
{
public partial class Form1 : Form
{
private const int THREADMAX = 3;
private ArrayList Files, Running;
private BackgroundWorker[] Bgw;
private Loader Ldr;
public Form1()
{
InitializeComponent();
Files = new ArrayList(10);
Bgw = new BackgroundWorker[THREADMAX];
Running = new ArrayList(THREADMAX);
Ldr = new Loader();
for (int x = 0; x < 10; x++) {
Files.Add(x.ToString());
}
}
private void button1_Click(object sender, EventArgs e)
{
string s;
timer1.Start();
while (Files.Count != 0) {
s = Files[0].ToString();
if (Running.Count < THREADMAX) {
for (int x = 0; x < THREADMAX; x++) {
if (Bgw[x] == null || !Bgw[x].IsBusy) {
Bgw[x] = new BackgroundWorker();
Bgw[x].DoWork += new DoWorkEventHandler(Ldr.Load);
Bgw[x].RunWorkerCompleted += new RunWorkerCompletedEventHandler(Done);
listBox1.Items.Add("Loading " + s);
Running.Add(s);
Bgw[x].RunWorkerAsync(s);
Files.Remove(s);
break;
}
}
}
Application.DoEvents();
}
}
private void Done(object sender, RunWorkerCompletedEventArgs e)
{
Running.Remove(e.Result.ToString());
listBox1.Items.Add("Load complete for " + e.Result.ToString());
}
private void timer1_Tick(object sender, EventArgs e)
{
if (Files.Count == 0 && Running.Count == 0) {
listBox1.Items.Add("Done!");
timer1.Stop();
}
}
}
public class Loader
{
public void Load(object sender, DoWorkEventArgs e)
{
e.Result = e.Argument.ToString();
Thread.Sleep(1000);
}
}
}
Thanks!
Source: http://community.livejournal.com/csharp/94902.html
-
MRE's and multithreading
Date: 03/08/08
Keywords: no keywords
I have worker threads where the running state is controlled by a ManualResetEvent object. It worked fine until I added a method call while the MRE is Reset (threads paused) and just before it is Set back. Now it appears that the threads don't resume. Is manipulating a "suspended" object messing up the MRE? Apparently it is; I would just like some insight.
Thanks.
Source: http://community.livejournal.com/csharp/94601.html
-
Show/Hide password
Date: 03/04/08
Keywords: asp
I have an ASP.NET application that I need to allow the user to view the input of a textbox with the textmode set to password by checking/unchecking a checkbox. I tried to just change the textmode to singleline and repost but that didn't work. Has anyone ever accomplished this. I am sure it is an easy implementation but I think I may be over complicating the issue.
Thanks
Source: http://community.livejournal.com/csharp/94287.html