|
Hello everybody,
I created application in C# on VS2010 and Windows 7, which use direct sound reference. Now I want to carry over exe file on PC with Windows XP. What should I do for running app - install NetFramework and? Or what problems can I expect.
thanks, Sam
PS : The PC dosen't have Internet connection, so I must to have all prepared.
|
|
|
|
|
Well, you'll have to make sure that you haven't targeted a feature in DirectX that isn't available in XP. The version of DirectX that ships with Windows 7 is a higher version than the one that you install on XP. And yes, you'll have to have the .NET Framework. If you use the Visual Studio installer to create a package, it should give you an indication of what else is needed and you can add the as merge modules if necessary.
|
|
|
|
|
You need to make sure direct sound dlls are either installed on your machine or install install them via a setup project.
|
|
|
|
|
Starting a new desktop application, I wonder whether I should stick with WinForms or try to learn WPF.
On the one hand, the application is quite simple, GUI-wise, and has no need for any blending or animation or other 'cool' things. It's a form-based application, of the classic type that's been a Windows staple for 20 years.
On the other hand, I've seen claims that WPF is the future.
Mind you, Win7 is only now being picked up, and Win8 still supports old desktop applications. Learning WPF as a gateway to Silverlight seems a bit pointless now that SL seems to have been dropped. It's also unlikely I'd try to migrate this app to the cloud - if I did, I'd probably re-write it in PHP or Python.
So that leaves WinRT. Is that the only reason for jumping to WPF?
(I should probably note that this is a hobby project - in my day job I'm a C++ developer, which I'm happy with, so I'm not interested in learning WPF to "further my career". I tend to write GUI-based applications in C#/Winforms though, as MFC is a dog.)
Grateful for reasoned advice.
|
|
|
|
|
Unless you want to learn WPF for some other reason, if you already know WinForms, it seems like it will do the job you want fairly straightforwardly so I would just use that. WPF lets you do lots of cool stuff but if you don't need any of that then it doesn't add all that much (data binding is a lot better but that can be worked around).
Orjan Westin wrote: On the other hand, I've seen claims that WPF is the future.
Other things that have been 'the future' include SVG, Silverlight and applications in the cloud.
|
|
|
|
|
The answer really depends on whether or not you see yourself moving towards writing Windows Store style applications (possibly the crappest name for a tech stack ever). If you are happy writing desktop applications and will continue only writing desktop applications then WinForms is a fine choice. If you see yourself wanting to write TTSFKAM (The Technology Stack Formerly Known As Metro) then knowing WPF will certainly help.
|
|
|
|
|
I suspect I'll have some other things later on, more suitable for TTSFKAM, but I'll burn that bridge when I get to it.
|
|
|
|
|
Orjan Westin wrote: On the other hand, I've seen claims that WPF is the future.
Microsoft stated that WPF is not a replacement-technology for WinForms. Contrary to the claims, it is not a dead technology. VB6 is, and even that still runs on Win8. Somehow I don't think you have to worry much on the platform going away
Orjan Westin wrote: So that leaves WinRT. Is that the only reason for jumping to WPF?
From what I heard, WPF does a nice job on decoupling the form from the code. A nice comparison can be found here[^].
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
WPF is quite different from winforms, more resembling a sort of web page than a form from a developing point of view (XAML).
That said, if you want to learn WPF, start with a book and a simple form, if you dive in because you need to animate things or do complex stuff it might blow up in your face.
IOW if you want to dive in WPF, this is not a bad project to do so, but winforms will work equally well in this case.
|
|
|
|
|
In your case, if it isn't critical (or this is for your employer and they're unahppy about supporting a different bit'o'the'framework) I'd go for WPF, just out of interest. I managed to architect a pretty large banking app that had about 10 lines of code runing behine the UI, most of which was exception handling stuff. If you do use WPF, see how it is used with MVVM.
|
|
|
|
|
I've done a lot of WinForms development; but once I started using WPF, I though WinForms was a "dog" ... all that dragging and dropping and positioning.
With WPF, I work almost exclusively in XAML and never in the "designer". With WPF, you can easily "flow" and scale controls, and never worry about absolute positioning.
While WinForms has one or more "layout" controls that help with positioning controls, WPF has much better support; so much so, I enjoy creating UI's (again).
|
|
|
|
|
WPF is still quite an immature technology. It is full of "featues". Just google for something like "WPF decimal comma" - and see many WTF solutions for such a simple thing as showing a decimal number corectly when you do not use an American number format. Try to change the value in the DateTimePicker with the keyboard - that does not work. When you changed the content of a text field, press enter to activate the default button (while the text field is still focussed), and the view model does not get updated. And many more such PITA. I prefer Windows Forms.
|
|
|
|
|
i want to get a values from sql server and that value hast to store in tree in c#.please help me
|
|
|
|
|
So you want to read data from SQL Server?
You'll need to create a SqlConnection[^] to connect to your database.
You'll need a SqlCommand[^] to issue the select command to the database.
Beyond that, you'll need to store the data in something. You can use a custom class, or a DataSet /DataTable .
Finally, you'll need to bind the data to the tree. How you do that depends on what technology stack you are using.
|
|
|
|
|
I am trying to develop a VSTO 2010 Word Addin. It has a custom task pane with a countdown timer (user control) in it. Idea is that when a word document is opened total time (in hours and minutes) is passed to the Addin which in turn passes it to the countdown timer control. When i run the addin in VS2010 and pass the user control two integers values i.e. hours and minutes in the Addin_Startup it works fine.
Now i am trying to open a word document on button click from an asp.net page. When i click the button a word document should open and time in hours and minutes should be passed to the addin which will then give it to the user control and the timer should run for the given time.
Problem is i cant figure out how to pass two integers to the addin and where to pass them. Following is my code which sometimes give "Catastrophic failure error" and other times it gives me "Unable to cast COM object of type 'System.__ComObject' to interface type 'MyWordAddin.IAddInUtilities'"
ThisAddin Class
namespace MyWordAddin
{
public partial class ThisAddIn
{
private ctlClock myUserControl;
private Microsoft.Office.Tools.CustomTaskPane myCustomTaskPane;
private int hour, min;
private AddInUtilities utilities;
protected override object RequestComAddInAutomationService()
{
if (utilities == null)
{
utilities = new AddInUtilities();
}
return utilities;
}
public int Min
{
get { return min; }
set { min = value; }
}
public int Hour
{
get { return hour; }
set { hour = value; }
}
public Microsoft.Office.Tools.CustomTaskPane MyCustomTaskPane
{
get { return myCustomTaskPane; }
set { myCustomTaskPane = value; }
}
public void ThisAddIn_Startup(object sender, System.EventArgs e)
{
myCustomTaskPane.VisibleChanged += new EventHandler(myCustomTaskPane_VisibleChanged);
}
public void setTime(int h, int m)
{
Hour = h;
Min = m;
myUserControl = new ctlClock(Hour, Min);
myCustomTaskPane = this.CustomTaskPanes.Add(myUserControl, "Remaining Time");
myCustomTaskPane.Visible = true;
}
private void yCustomTaskPane_VisibleChanged(object sender, System.EventArgs e)
{
Globals.Ribbons.ManageTaskPaneRibbon.toggleButton1.Checked = myCustomTaskPane.Visible;
}
private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
{
}
AddinUtilities class
namespace MyWordAddin
{
[ComVisible(true)]
[InterfaceType(ComInterfaceType.InterfaceIsDual)]
public interface IAddInUtilities
{
void setAddinTime(int h, int min);
}
[ComVisible(true)]
[ClassInterface(ClassInterfaceType.None)]
public class AddInUtilities : StandardOleMarshalObject,IAddInUtilities
{
public void setAddinTime(int hour, int min)
{
Globals.ThisAddIn.setTime(hour, min);
}
}
}
Controller Application which tries to open word document and send two integers to the addin
namespace ControllerApplication
{
public class CCWordApp
{
private Word._Application oWordApp;
public Word._Application OWordApp
{
get { return oWordApp; }
set { oWordApp = value; }
}
private Word.Document oWordDoc;
public Word.Document OWordDoc
{
get { return oWordDoc; }
set { oWordDoc = value; }
}
public CCWordApp()
{
oWordApp = new Word.Application();
oWordDoc = new Word.Document();
}
public void Open()
{
object addinName = "MyWordAddIn";
Microsoft.Office.Core.COMAddIn addin = oWordApp.COMAddIns.Item(addinName);
IAddInUtilities utils = null;
utils = (IAddInUtilities)addin.Object;
utils.setAddinTime(0, 8);
Object oMissing = System.Reflection.Missing.Value;
oWordApp.Visible = true;
oWordDoc = oWordApp.Documents.Add(ref oMissing, ref oMissing, ref oMissing, ref oMissing);
oWordDoc.Activate();
}
When i run the controller application, upon click event of start button it some times give me "Catastrophic failure" other times it gives me "Unable to cast COM object of type 'System.__ComObject' to interface type 'MyWordAddin.IAddInUtilities'" and sometimes it stucks on the last line of code saying "An object instance not passed to and object". I have bold selected the code where error arises. I cant figure out what really is the problem here and why i cant pass two simple integers to my addin. There sure be something i am doing in a very wrong manner. Please guide me.
|
|
|
|
|
Shah Ali Haider wrote: Now i am trying to open a word document on button click from an asp.net page.
I think that's the problem - Office automation is not supported on the server:
Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, ASP.NET, DCOM, and NT Services), because Office may exhibit unstable behavior and/or deadlock when Office is run in this environment.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Shah - I'm sorry that I can't offer a constructive solution other than to agree that the issue sounds likely because you are trying to run it on an ASP.NET server. Try running the add-in on a stand alone box and see what the behaviour is there.
On a side not, let me congratulate you on asking your question in the way you have. You outlined what the problem was, gave us just enough code to provide context, highlighted where the problem was, and generally crafted the question in such a way that it pains me not to give you a definitive answer - I would love to say, "oh you need to initialise X to get this to work". Congratulations on such an excellent question - if there were more like yours, people would be falling over themselves to answer questions here.
|
|
|
|
|
WebRequest and WebResponse has issues
I wrote a C# program that uses WebRequest and WebResponse to perform a simple web crawler. I discovered something about web sites. Web browsers such as IE and FireFox offer the capacity to view the HTML source code. But it seems that html code that is sent to the browser is one thing and what the browser interprets and displays is something else. For example, if you run a google search in IE and run the same google search in FireFox, the content that you can see when you view the source in IE will NOT have the hyperlinks and content from the search results, but you can see the html hyperlinks and content from the search results when you view the source in FireFox. So my question is this. How do you specialise the WebRequest and WebResponse to show the content after it is processed by the browser instead of before?
|
|
|
|
|
Xarzu wrote: WebRequest and WebResponse has issues
No, really they dont. What you go on to describe has nothing to do with the way you make an http, ftp or any other sort of request/response using WebRequest and WebResponse.
Makers of browsers are free to parse and change the raw content they get from a web server in any way they see fit, what you are doing is making the raw request and getting back the raw response. Using the classes you mention, you will have no way of showing the "content after it is processed by the browser". The only way to do that is get the browser (or an embedded web browser control) to make the request for you.
I suspect the real problem you're facing is badly formatted, or even invalid HTML. In which case this is a known problem with many solutions - the most common of which is probably the HTML Agility pack[^]
|
|
|
|
|
Just to be clear, my goal is to programatically get search results from a google search.
After looking closely at the different html source from IE and firefox and seeing the point at which they start to differ, I can safely conclude that what is happening is that firefox is showing the html prior to the browser running the javascript and IE is showing the html that results after javascript has been processed by the browser.
I think maybe I need to format what I sent to the WebRequest.Create method, but the question I know have is this. How do I send to this method the desire that I want to create the WebRequest such that I set the visibility to hidden. I believe that therein might lie the key to getting this done. It seems that the javascript processes the html in IE because the visibility is not hidden.
|
|
|
|
|
Quote: after it is processed by the browser instead of before? And what do you mean by that? It is not hard really to differentiate html across browsers. Google is known from that. To get html for FireFox, IE, Android etc. just change UserAgent HTTP header:
http://tools.ietf.org/html/rfc2616#section-14.43[^]
No more Mister Nice Guy... >: |
|
|
|
|
|
Agree 100%.
This can be accomplished by checking the Request.UserAgent in ASP.NET and the sending different output. Easy way to optimise your code for each browser and not to have to send everything down the wire.
|
|
|
|
|
my goal is to programatically get search results from a google search.
Using WebRequest and WebResponse yelds results like I see in IE where the (if I look at the processed HTML source) javascript manages to hide the search engine results from google after the browser processes the javascript.
The source code from Firefox is before html is processed by the browser and the javascript manages to hide the content.
How do I programatically make web requests to be like it is in Firefox?
|
|
|
|
|
I don't get it. If you wan't to get html for FF just use FF User-Agent.
If you want to have HTML after it is swallowed by JS then I have 2 questions: why you need this anyway? why do you think it is even doable in C#, it's JS code how are you imagine to execute JS code by c# program?
No more Mister Nice Guy... >: |
|
|
|
|
|
the source display in IE differs from FireFox on the exact same page.
If you use google in these two browsers, IE manages to have the resulting content -- the search result -- hidden in the html source.
|
|
|
|