|
which OS?
I have all VS2008 Express packages installed on Vista-32 which probably is at SP1.
|
|
|
|
|
|
George,
1. I don't know what that thing is your link points to
2. IIRC: For XP you should be at SP3 (SP2 at least) for anything recent
3. I downloaded Visual Studio 2008 long ago from here[^]
Cheers.
|
|
|
|
|
I have XP w/SP3 but when I start my Vis 2008 Express there is no icon for Web Services App's
|
|
|
|
|
electriac wrote: Vis 2008 Express
that does not exist.
There are SEPARATE Express products for C#, C++, VB.NET, SQL and Web Design. See the earlier link.
You can install any subset of them next to each other.
|
|
|
|
|
Quick Q for the interop specialists among us:
I have a COM object written in a VB6 legacy app.
The public method I'm trying to call is something like this in VB6:
Public Function MyFunc(ByRef theDictionary As Dictionary) as Long
' ... do stuff
End Function
The VB6 project has a Reference to "Microsoft Scripting Runtime".
In C#, I've imported this vb6 type w/ the type library importer, and have a reference to "Microsoft Scripting Runtime", ie: Interop.Scripting.dll in my C# project.
When I call this class from C#, like so:
public int CallMyFunc()
{
Vb6Type vbObj = new Vb6TypeClass();
Scripting.Dictionary vbDictionary = new Scripting.DictionaryClass();
...
int retVal = vbObj.MyFunc(ref vbDictionary);
....
}
I end up w/ a compiler error that doesn't make sense to me:
Error 3 Argument '1': cannot convert from 'ref Scripting.Dictionary [c:\...\Interop.Scripting.dll]' to 'ref Scripting.Dictionary []'
Note that it can't convert the variable vbDictionary to an array of Scripting.Dictionary. Intellisense will show the parameter type as "ref Scripting.Dictionary theDictionary", hitting F12 takes me to a function of the imported type that looks like this:
[DispId(1234)]
int MyFunc(ref Dictionary theDictionary);
Any suggestions? I have the source for the VB6 and I'm actaully calling a wrapper which has the same signature. I'm about to create a custom type in vb to wrap this and avoid the drama.
|
|
|
|
|
Wes Jones wrote: Scripting.Dictionary vbDictionary = new Scripting.DictionaryClass();
Do you need to use a DictionaryClass ?
Can you try using just Scripting.Dictionary vbDictionary = new Scripting.Dictionary(); ?
There's nothing left in my right brain and nothing right in my left brain. |
|
|
|
|
|
I have a Visual Studio 2008 Windows Service application that is working wonderfully with 1 exception.
The CPU process shows 49 or 50 percent in Windows Task Manager. I'm sure it is because I have in a Continuous loop, but I'm not sure of the best way to adjust in a service because I do want it to check for files to process continually.
How can I modify to reduce CPU process usage?
Any and all advice welcomed.
Here is a code snippet :
public Service1()
{
InitializeComponent();
if (!System.Diagnostics.EventLog.SourceExists("AppNameLogSource"))
{
System.Diagnostics.EventLog.CreateEventSource("AppNameLogSource", "AppNameLog");
}
eventLog1.Source = "AppNameLogSource";
eventLog1.Log = "AppNameLog";
}
static void Main()
{
System.ServiceProcess.ServiceBase[] ServicesToRun;
ServicesToRun = new System.ServiceProcess.ServiceBase[] { new AppNameService.Service1() };
System.ServiceProcess.ServiceBase.Run(ServicesToRun);
}
protected override void OnStart(string[] args)
{
eventLog1.WriteEntry("AppName Service has started");
var worker = new Thread(AppNameService);
worker.Name = ("AppNameServiceWorker");
worker.IsBackground = false;
worker.Start();
}
protected override void OnStop()
{
eventLog1.WriteEntry("AppName Service has stopped.");
}
protected override void OnContinue()
{
eventLog1.WriteEntry("AppName Service is continuing and working.");
}
void AppNameService()
{
string sRetVal;
string sRetVal2;
string sFileName;
string sImportDir;
string sTypeImportFile;
int iInt1;
int iInt2;
Boolean bolContinueService = true;
sWinDir = System.Environment.GetEnvironmentVariable("windir");
sRetVal = Get_AppSettings((sWinDir + "\\AppNameServiceAppSettings.ini"));
do
{
try
{
sRetVal = Get_AppNameServiceList((sWinDir + sAppNameServiceListName));
Boolean bolCompareValue = false;
bolCompareValue = CompareStrings(sRetVal, "Success");
if (bolCompareValue == true)
{
iInt1 = 0;
do
{
(Run of a Subroutine that looks and sees if there are files to process.
It will set the bolFilesToProcess = True if it finds any files
Or set the bolFilesToProcess = False if there are not.)
if (bolFilesToProcess == true)
{
iInt1 = iNumberOfINIs;
}
}
while (iInt1 < iNumberOfINIs);
if (bolFilesToProcess == true)
{
eventLog1.WriteEntry("Call AppName to process new files found.");
using (System.Diagnostics.Process exeProcess = System.Diagnostics.Process.Start(@sApp2Executable, @"/r"))
{
exeProcess.WaitForExit();
}
eventLog1.WriteEntry("AppName completed processing of files.");
}
}
}
catch (Exception ex)
{
bolContinueService = false;
sErrorMessage = "Error in AppName Service Continuous process Loop. Error: " + ex.Message;
eventLog1.WriteEntry(sErrorMessage, EventLogEntryType.Error);
}
finally
{
GC.Collect();
}
}
while (bolContinueService == true);
eventLog1.WriteEntry("ContinueService Process has stopped due to Internal Service Error. - AppNameService ");
}
modified on Saturday, December 12, 2009 7:47 AM
|
|
|
|
|
50% probably is all CPU power of a dual-core.
I would look into your code if it were posted in PRE tags, preserving indentation.
You could still edit your message to that effect. Thanks.
|
|
|
|
|
I edited the post saving with PRE-Tags to perserve the indentation.
|
|
|
|
|
Thanks for PRE tags.
I'm replying here as this allows me to still see your code while I type.
IMO the problem is this: AppNameService contains one big loop (do ... while bolContinue), which contains some conditional tests. In one path a blocking method (WaitForExit) is called; in all other execution paths (when bolCompareValue is false or when bolFilesToProcess is false), the code never becomes idle, hence uses all available cycles to hurry up and start the next loop iteration.
There are a couple of ways to fix this:
1. the easy one: when nothing needs to be done in an iteration, call Thread.Sleep(100) to relinquisg the CPU for 100 msec, or whatever number that looks fine, but not below 10, as that is about equal to the system's tick resolution (see my Timers article).
2. the more economical one: if possible, make everything event-driven, i.e. don't poll (=check for certain conditions) at all, just tell the party responsible for those conditions to send you a signal. This isn't always possible.
Some additional comments:
1. there is no need to write if (booleanFlag==true) ... , a simple if (booleanFlag) ... behaves identically in C#.
2. in your try block, you are logging the Exception.Message but ignoring all the extra information that may be present in the Exception, and only gets visible by looking at its remaining properties (or easier: by looking at Exception.ToString(); I recommend keeping a log file with all the ToString() results, assuming they would be too much to put into the existing eventLog)
3. I don't like explicit GC.Collect() calls; maybe it is OK or even good in a service, I would certainly ban them from interactive programs.
|
|
|
|
|
Thank you very much for the advice and quick response. I will apply your service suggestion on Monday when I return to work and then reply back with the method that worked. Also thank you for the general C# coding recommendations.
|
|
|
|
|
Option 1 (Thread.Sleep(100);) worked beutifully as Luc Pattyn suggested. Thank you!
}
}
Thread.Sleep(100);
}
catch (Exception ex)
{
bolContinueService = false;
sErrorMessage = "Error in DocumentShuttle Service " + sAssemblyVersion + " Continuous process Loop. Error: " + ex.Message;
sRetStatusErrorLog = WriteInLog(sErrorMessage);
eventLog1.WriteEntry(sErrorMessage, EventLogEntryType.Error);
}
|
|
|
|
|
Anyone knows how to handle the code in chapter 26 from the book "Microsoft Visual C# Step by Step"? This example runs well except for adding a row to the listview control that is biding with the Northwind database, I tryed everything but it seems the problem is the data binding and the listview control that doesn't recognize the format of the table problably because the table is joined with another table and the listview control refers to only one table. I will post the code that gives a the runtime error later.
|
|
|
|
|
i used this code to play a video on a panel control
using Microsoft.DirectX.AudioVideoPlayback;
private void open(string path)
{
try
{
myvideo = new Video(path);
myvideo.Owner =panel1;
myvideo.Play();
}
catch
{
}
}
but when i run the program it keeps saying
"Loader Lock was detected:
DLL 'C:\Windows\assembly\GAC\Microsoft.DirectX\1.0.2902.0__31bf3856ad364e35\Microsoft.DirectX.dll' is attempting managed execution inside OS Loader lock. Do not attempt to run managed code inside a DllMain or image initialization function since doing so can cause the application to hang."
if i press the run button again it continues excuting normally. What's wrong with the code and how do i fix it???
modified on Friday, December 11, 2009 2:14 PM
|
|
|
|
|
I Could be bug, Please try to update DirectX to newest. I Know that Microsft didn't update Managed Direct X for quite a while. You coud look at the alternative:
slimDX[^]
|
|
|
|
|
Hello
I would like to know difference betwen casting and if there is one, then in which conditions shroud be used
Example:
TextBox txt = new TextBox;
Object obj = txt;
// What is the difference between these 2 castings
TextBox txt1 = (TextBox) txt;
TextBox txt2 = txt as TextBox;
This may be stupid question but thanks in advance
|
|
|
|
|
|
And in general, I prefer using 'as', but it depends on your situation. If you want an exception to be thrown, use explicit casting (ex. "((TextBox)obj) "). Generally, its good to avoid exceptions unless there's just nothing you can do to avoid the 'exceptional' behavior.
|
|
|
|
|
Thanks to both replies. Those answer extinguish my curiosty
|
|
|
|
|
Also, the C-style cast can be overloaded, but as can not be overloaded.
|
|
|
|
|
I've created a control to embed a MSWord document based on several projects here. The embeding it's self works great but I am having trouble figuring out how to bind event handlers. See below for an example.
Word.DocumentBeforeClose += new ApplicationEvents4_DocumentBeforeCloseEventHandler(OnClose);
The above line works with doing early binding, but due to the variations in version of Office being used in the company, I need to do late binding. Anyone got any ideas?
Thank you,
Eric Ritzie
|
|
|
|
|
I Don't think you can do it that way. There are 2 options that I thought:
1. Option:
Install same version of Office
2. Option:
Use different module (dll) based on Office installed
3. Option: (I Don't know how to do it in C#
Use compiler directive and compile different exe files
|
|
|
|
|
Hmmm.....Option 1 is not really feesable because of cost. Options 2 and 3 would be a big pain although they are doable.
I think there has to be a way to do what I am trying to accompish biw the Interop. I'm able to get and set properties by using type.InvokeMember() and I can even get an event object by using type.GetEvent(), I just need that last little bit to bind it to my event handlers.
Thank you,
Eric Ritzie
|
|
|
|
|
I am at a lost. I have verified what I am doing against the documentation on microsofts website:
http://msdn.microsoft.com/en-us/library/aa392154(VS.85).aspx[^] and I just can't figure out why it would give me this error.
My Connection object is not shown as it is global within the class I have it in. I am connect to this machine that is not on the domain and get installed applications, all services, and computer information. The problem is it keeps throwing a "Invalid Method Parameter(s)" error.
In case your wondering.. I ran a foreach look on the inParams.Properties and verified that all the method parameters existed in the inParams (which it does).
Any help would be great!
public string Join(string dns, string domain, string username, string password)
{
try
{
ManagementScope scope = new ManagementScope(@"\\" + dns + @"\root\CIMV2", conn);
ManagementPath path = new ManagementPath("Win32_ComputerSystem");
ManagementClass mgmtClass = new ManagementClass(scope, path, null);
ManagementBaseObject inParams = mgmtClass.GetMethodParameters("JoinDomainOrWorkgroup");
inParams["Name"] = domain;
inParams["UserName"] = username;
inParams["Password"] = password;
inParams["AccountOU"] = null;
inParams["FJoinOptions"] = (UInt32)1;
ManagementBaseObject outParams = mgmtClass.InvokeMethod("JoinDomainOrWorkgroup", inParams, null);
string status = ReturnedValue.JoinDomainOrWorkgroup(Convert.ToInt32(outParams["ReturnValue"]));
return status;
}
catch (Exception ex)
{
EventLog.WriteEntry("ADEM Application", ex.Message, EventLogEntryType.Error);
return ex.Message;
}
}
|
|
|
|