|
In my 3 layer application, while I try to compile my business layer, I was getting the following error:
"Task failed because "sgen.exe" was not found, or the correct Microsoft Windows SDK is not installed. The task is looking for "sgen.exe" in the "bin" subdirectory beneath the location specified in the InstallationFolder value of the registry key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v6.0A. You may be able to solve the problem by doing one of the following: 1) Install the Microsoft Windows SDK for Windows Server 2008 and .NET Framework 3.5. 2) Install Visual Studio 2008. 3) Manually set the above registry key to the correct location. 4) Pass the correct location into the "ToolPath" parameter of the task. CnCCore"
This is happening only when I try to compile the project in Release Mode. While compiling in Debug mode, there are no issues. It would be great if anybody can provide some solution to resolve this issue.
I googled the error for sometime. Majority of the solution says, to write the key in registry or reinstall the .Net Framework 3.5 version. Is there any other better possible way to avoid this?
I am not sure how to do the fourth resolution. Is this again, writing in registry?
Thanks in advance,
meeram395
Success is the good fortune that comes from aspiration, desperation, perspiration and inspiration.
|
|
|
|
|
Have you checked the path as listed above to ensure that it exists, and that sgen.exe is present in the bin sub-directory?
I must get a clever new signature for 2011.
|
|
|
|
|
meeram395 wrote: This is happening only when I try to compile the project in Release Mode.
That is a clue. Check and compare your debug and release configuration. I'm going to take a wild guess of missing path in release config.
|
|
|
|
|
Am I the only fool using .NET in here?... haha
In the process I´ve explained here the property Process::HasExited is true from the moment the process starts.
The same occurs with the method void extProcessWorkCompleted (System::Object^ /*sender*/, System::ComponentModel::RunWorkerCompletedEventArgs^ e) which is called when the process starts, and not when it actually finishes.
Has this something to do with the process´s code or am I doing something wrong?
|
|
|
|
|
piul wrote: Am I the only fool using .NET in here?
I don't know.
piul wrote: am I doing something wrong?
Most probably.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Well... I was trying to make a joke, nothing else. I´m sorry if that dissapointed someone.
|
|
|
|
|
No one is disappointed. It is NOT sensible to rewrite about same question.
And we have Message Type, which has Joke in it.
If you want to Joke, come and have a good joke at Lounge.
|
|
|
|
|
Foolish,
The extProcessWorkCompleted event is raised when the process starts? Definitely someone has got it wrong. Couldn't see any MSDN documentation on extProcessWorkCompleted so I'm guessing it's you.
"You get that on the big jobs."
|
|
|
|
|
piul wrote: The same occurs with the method void extProcessWorkCompleted (System::Object^ /*sender*/, System::ComponentModel::RunWorkerCompletedEventArgs^ e) which is called when the process starts, and not when it actually finishes.
Some executables finish immediately after spawning a child-proces. Can you compare the Process-ID of the executable that you started to the one that seems to be running?
I are Troll
|
|
|
|
|
I have a time consuming process that is called from a Windows forms application and run asynchronously in another thread, when the user clicks on runButton
extProcess = gcnew System::Diagnostics::Process;
extProcess->StartInfo = gcnew System::Diagnostics::ProcessStartInfo;
extProcess->StartInfo->RedirectStandardOutput = true;
extProcess->StartInfo->UseShellExecute = false;
extProcess->StartInfo->FileName = EXTPROC_EXE;
extProcess->StartInfo->CreateNoWindow = true;
extProcess->OutputDataReceived += gcnew System::Diagnostics::DataReceivedEventHandler (this, &Form1::StdoutHandler);
try
{
extProcessThread->RunWorkerAsync();
The thread is launched and the standard output is read, to be shown in real time in a textBox in the main window
void extProcessThreadDoWork (System::Object^ sender, System::ComponentModel::DoWorkEventArgs^ e)
{
extProcess->Start();
extProcess->BeginOutputReadLine();
}
void Form1::StdoutHandler (Object ^ sender,
System::Diagnostics::DataReceivedEventArgs ^output)
{
textBox->AppendText (output->Data + "\n");
}
The problem comes in this last line. An exception is launched "Control accessed from a thread other than the thread it was created on"
I do understand why, but I don´t know how to solve it...
|
|
|
|
|
|
You need to have a look at the invoke methods in the article shown by the other poster
MSDN: Look at the example at the bottom of the page[^]
As barmey as a sack of badgers
Dude, if I knew what I was doing in life, I'd be rich, retired, dating a supermodel and laughing at the rest of you from the sidelines.
|
|
|
|
|
This[^] explains it, however all examples are C# or VB.NET; same principles apply to C++/CLI.
Amd a BackgroundWorker's ProgressChanged and RunWorkerCompleted handlers don't have the cross-thread problem as they run on the thread that created the BGW, which normally is the main thread. That is one of the big advantages of BGW.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
I have a windows Forms application that calls a mathematical calculations .exe
superMinerProcess->Start();
superMinerProcess->BeginOutputReadLine();
while (!superMinerProcess->HasExited)
{
If I set a breakpoint after the Start(); the program only reaches it after the process has finished. I don't understand... Any idea?
|
|
|
|
|
That is inconclusive. Where is this code located? what is in the while loop? what is it you are trying to achieve?
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
The application is a dialog that runs a long mathematical calculation (the external process, an independent executable) when pressing a Run button. Hence, this code is located within the buttonRun_Click function.
while (!superMinerProcess->HasExited)
{
if (processCancelled)
{
processCancelled = false;
break;
}
}
processCancelled is set to true in buttonCancel_Click . What I´m trying is to be able to kill the process when the user clicks on the Cancel button. I´ve tried writing superMinerProcess->Kill() in buttonCancel_Click but it won´t work because the Cancel button is just not clickable while the process is running.
Here´s the rest of relevant code of the process
superMinerProcess = gcnew System::Diagnostics::Process;
superMinerProcess->StartInfo = gcnew System::Diagnostics::ProcessStartInfo;
superMinerProcess->StartInfo->RedirectStandardOutput = true;
superMinerProcess->StartInfo->UseShellExecute = false;
superMinerProcess->StartInfo->FileName = SUPERMINER_EXE;
superMinerProcess->StartInfo->CreateNoWindow = true;
superMinerProcess->StartInfo->Arguments = getArguments();
superMinerProcess->OutputDataReceived += gcnew System::Diagnostics::DataReceivedEventHandler (&Form1::StdoutHandler);
|
|
|
|
|
OK, that is quite wrong for several reasons:
1.
the while loop has no blocking calls, so it will spin at full speed, consuming all cycles of one (perhaps the only) core. If you must have a polling loop like that, at least slow it down by inserting say Thread.Sleep(100);
However it is in general better to avoid a polling loop.
2.
It is not OK to halt the main thread like that, as the whole GUI will freeze. If e.g. another window pops up on top of your app, and then goes away again, your app won't repaint itself.
The correct approach would be:
- to have a separate thread (I suggest a BackgroundWorker) which launches the process, captures its output, and waits for its termination;
- to launch this thread from your button click handler (possibly also disabling said button, turning the cursor into a wait cursor, etc);
- to have a delegate dealing with intermediate results (maybe showing them in a ListBox);
- to have another delegate dealing with the termination of the process (restoring the GUI back to normal).
BTW: said thread would not need a polling loop on superMinerProcess->HasExited , as it could use superMinerProcess->WaitForExit()
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
I like the idea of having the process in a different thread. It does work much better.
However I have a problem when it comes to display in my form the text captured from the process. I have a delegate superMinerThreadWorkCompleted in charge of displaying the results.
void superMinerThreadWorkCompleted (System::Object^ sender, System::ComponentModel::DoWorkEventArgs^ e)
{
textBox = "Process text";
}
But I get the error
C3352: superMinerThreadWorkCompleted(System::Object ^,System::ComponentModel::DoWorkEventArgs ^)' : the specified function does not match the delegate type 'void (System::Object ^,System::ComponentModel::RunWorkerCompletedEventArgs ^)'<br />
1>Form1.cpp in the line
superMinerThread->RunWorkerCompleted += gcnew System::ComponentModel::RunWorkerCompletedEventHandler (&Form1::superMinerThreadWorkCompleted);
I can fix this by making the delegate static but then I cannot modify member class textBox .
What could be the way around this?
|
|
|
|
|
piul wrote: DoWorkEventArgs
piul wrote: RunWorkerCompletedEventArgs
these are different! the former is just wrong.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Changed the delegate to
void superMinerThreadWorkCompleted (System::Object^ sender,
System::ComponentModel::RunWorkerCompletedEventArgs^ e)
{}
and still got the same error
'void SuperMinerGUI::Form1::superMinerThreadWorkCompleted(System::Object ^,System::ComponentModel::RunWorkerCompletedEventArgs ^)' : the specified function does not match the delegate type 'void (System::Object ^,System::ComponentModel::RunWorkerCompletedEventArgs ^)'<br />
1>Form1.cpp
|
|
|
|
|
for non-static (instance) delegates, you need a constructor that takes two arguments, the first being this .
superMinerThread->RunWorkerCompleted += gcnew System::ComponentModel::RunWorkerCompletedEventHandler
(this, &Form1::superMinerThreadWorkCompleted);
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
|
I have 2 classes both of which are not trying to call a userform but I keep getting this error:
<br />
An error occurred creating the form. See Exception.InnerException for details. The error is: The form referred to itself during construction from a default instance, which led to infinite recursion. Within the Form's constructor refer to the form using 'Me.'<br />
This is the code to my form1:
Public Class Form1
Dim getwmi As New wmiget()
Dim smtp As New smtp()
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
getwmi.Main()
End Sub
Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
tbAt.Clear()
FindAttachment.Title = "Please select a file"
FindAttachment.InitialDirectory = Environment.GetEnvironmentVariable("userprofile") + "\Desktop"
FindAttachment.ShowDialog()
End Sub
Private Sub FindAttachment_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles FindAttachment.FileOk
Dim filepath As System.IO.FileStream = FindAttachment.OpenFile()
tbAt.Text = FindAttachment.FileName.ToString.ToLower()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
tbTo.Clear()
tbFr.Clear()
tbSu.Clear()
tbBo.Clear()
tbSe.Clear()
tbAt.Clear()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If tbUs.Text = "" And tbPa.Text = "" Then
MsgBox("Smtp:[" + tbSe.Text + "]: requires a username and password to continue")
End If
smtp.smtp()
End Sub
End Class
This is the code to my smtp class:
Imports System.Net.Mail
Public Class smtp
Dim username As String = Form1.tbUs.Text
Dim password As String = Form1.tbPa.Text
Public Sub smtp()
Try
'Start by creating a mail message object
Dim MyMailMessage As New MailMessage()
'From requires an instance of the MailAddress type
MyMailMessage.From = New MailAddress(Form1.tbFr.Text.ToLower())
'To is a collection of MailAddress types
MyMailMessage.To.Add(Form1.tbTo.Text.ToLower())
MyMailMessage.Subject = Form1.tbSu.Text
MyMailMessage.Body = Form1.tbBo.Text
'Add attachment
Dim attachFile As New Attachment(Form1.tbAt.Text)
MyMailMessage.Attachments.Add(attachFile)
'Create the SMTPClient object and specify the SMTP server
Dim SMTPServer As New SmtpClient(Form1.tbSe.Text.ToLower())
SMTPServer.Port = 587
SMTPServer.Credentials = New System.Net.NetworkCredential(username, password)
SMTPServer.EnableSsl = True
Try
SMTPServer.Send(MyMailMessage)
MsgBox("Email Sent Successfully.", vbInformation, "Email Notification")
username = ""
password = ""
Catch ex As SmtpException
MessageBox.Show(ex.Message)
End Try
Catch EX As Exception
MessageBox.Show(EX.Message)
End Try
End Sub
End Class
And this is the code to which my error is pointing to:
'------------------------------------------------------------------------------
' <auto-generated>
' This code was generated by a tool.
' Runtime Version:4.0.30319.1
'
' Changes to this file may cause incorrect behavior and will be lost if
' the code is regenerated.
' </auto-generated>
'------------------------------------------------------------------------------
Option Strict On
Option Explicit On
Namespace My
'NOTE: This file is auto-generated; do not modify it directly. To make changes,
' or if you encounter build errors in this file, go to the Project Designer
' (go to Project Properties or double-click the My Project node in
' Solution Explorer), and make changes on the Application tab.
'
Partial Friend Class MyApplication
<Global.System.Diagnostics.DebuggerStepThroughAttribute()> _
Public Sub New()
MyBase.New(Global.Microsoft.VisualBasic.ApplicationServices.AuthenticationMode.Windows)
Me.IsSingleInstance = false
Me.EnableVisualStyles = true
Me.SaveMySettingsOnExit = true
Me.ShutDownStyle = Global.Microsoft.VisualBasic.ApplicationServices.ShutdownMode.AfterMainFormCloses
End Sub
<Global.System.Diagnostics.DebuggerStepThroughAttribute()> _
Protected Overrides Sub OnCreateMainForm()
Me.MainForm = Global.TeamSpec.Form1
End Sub
End Class
End Namespace
I cant seem to revert my changes and get rid of the error, i mean i have reverted the changes but its still throwing it at me.
|
|
|
|
|
Without running your code in Visual Studio, hit F10 to step through the code line by line until you get back to a part where you already were.
The piece you're not showing is the getwmi class and its main method. I have a feeling you're making a reference to Form1 in there somewhere.
|
|
|
|
|
Herboren wrote: And this is the code to which my error is pointing to:
An expception points to a single line, which line is it?
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|