PDA

View Full Version : مشکل در اجرای خودکار برنامه



Collector
شنبه 12 شهریور 1390, 22:15 عصر
سلام

من وقتی برنامه را به صورت دستی اجرا میکنم برنامه عادی اجرا میشه.
ولی وقتی با این کد در رجیستری برنامه به صورت خودکار اجرا میشود. مشکل پیش میاید.


RegistryKey key = Registry.LocalMachine.CreateSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run");
key.SetValue("Mo", "C:\\Program Files\\Mo\\Mo\\WindowsFormsApplication3.exe", RegistryValueKind.String);





See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.NullReferenceException: Object reference not set to an instance of an object.
at Sunisoft.IrisSkin.InternalControls.x3c41176af7e54b 01.x9954cbb39675570d()
at Sunisoft.IrisSkin.InternalControls.x3c41176af7e54b 01.set_xd8e8992926cad390(Form xbcea506a33cf9111)
at Sunisoft.IrisSkin.xa427f1b2281f554b.x30c11b5a89921 b08()
at Sunisoft.IrisSkin.xa427f1b2281f554b..ctor(IntPtr handle, SkinEngine engine)
at Sunisoft.IrisSkin.SkinEngine.DoAddWnd(IntPtr handle, Boolean isManual)
at Sunisoft.IrisSkin.SkinEngine.FnHookProc(Int32 nCode, IntPtr wParam, IntPtr lParam)
at System.Windows.Forms.SafeNativeMethods.ShowWindow( HandleRef hWnd, Int32 nCmdShow)
at System.Windows.Forms.Control.SetVisibleCore(Boolea n value)
at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
at System.Windows.Forms.Control.set_Visible(Boolean value)
at System.Windows.Forms.Application.ThreadContext.Run MessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.Run MessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.RunDialog(Form form)
at System.Windows.Forms.Form.ShowDialog(IWin32Window owner)
at System.Windows.Forms.Form.ShowDialog()
at WindowsFormsApplication3.loading.timer1_Tick(Objec t sender, EventArgs e)
at System.Windows.Forms.Timer.OnTick(EventArgs e)
at System.Windows.Forms.Timer.TimerNativeWindow.WndPr oc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

cardano7
یک شنبه 13 شهریور 1390, 09:34 صبح
مطمنی که قبل از اجرای برنامه ات نیاز نیست برنامه ی دیگری اجرا شود؟

Collector
یک شنبه 13 شهریور 1390, 12:06 عصر
مطمنی که قبل از اجرای برنامه ات نیاز نیست برنامه ی دیگری اجرا شود؟

طبق این ارور از یک کامپوننت ایراد میگیره که اون کامپوننت کنار برنامه هست.
مثلا چه برنامه ای ؟ موقع اجرا هیچ برنامه به غیر از فایل اجرایی اجرا نمیکنم. لطفا بیشتر توضیح دهید !!!

Esmail Solhkhah
یک شنبه 13 شهریور 1390, 23:43 عصر
شما برنامه رو وقتی خودتون هم اجرا میکنید دقیقا از همین مسیر اجرا میکنید ؟

ظاهرا با توجه به خطایی که دارید کنترل Sunisoft.IrisSkin دچار مورد شده

احتمالا یکی از فایلهاشو نمیتونه پیدا کنه

Collector
دوشنبه 14 شهریور 1390, 00:32 صبح
شما برنامه رو وقتی خودتون هم اجرا میکنید دقیقا از همین مسیر اجرا میکنید ؟

ظاهرا با توجه به خطایی که دارید کنترل Sunisoft.IrisSkin دچار مورد شده

احتمالا یکی از فایلهاشو نمیتونه پیدا کنه

بله از همین مسیر اجرا میکنم.
کدوم فایلش رو نمیتونه پیدا کنه .
امکانشه هست که یک مکان ریجیستری دیگر ر و معرفی کنید تا امتحان کنم.
این برنامه در استارت آپ بدون مشکل اجرا میشه.

Esmail Solhkhah
دوشنبه 14 شهریور 1390, 00:54 صبح
مسیر ریجستری درسته

اگه میشه کدتون رو بذارید اینجا بنده یا دوستان بررسی کنیم

Collector
دوشنبه 14 شهریور 1390, 16:41 عصر
مسیر ریجستری درسته

اگه میشه کدتون رو بذارید اینجا بنده یا دوستان بررسی کنیم

برنامه به صورت دستی با گرافیک اجرا میشه ولی به صورت خودکار خیر.

Esmail Solhkhah
دوشنبه 14 شهریور 1390, 17:00 عصر
بجای
Environment.CurrentDirectory
بذارید
Application.StartupPath
موفق باشید.

Collector
دوشنبه 14 شهریور 1390, 19:43 عصر
من کد را تغییر دادم مشکل اسکین با آن کنترل درست شد.

اما خطای SQL میدهد.
اگر اشتباه نکنم زود تر از سرویس SQL Server اجرا میشود.
لطفا بررسی کنید.


Unhandled exception has occurred in your application. If you click
Continue, the application will ignore this error and attempt to continue. If
you click Quit, the application will close immediately.

A network-related or instance-specific error occurred while establishing a
connection to SQL Server. The server was not found or was not
accessible. Verify that the instance name is correct and that SQL Server
is configured to allow remote connections. (provider: Named Pipes
Provider, error: 40 - Could not open a connection to SQL Server).

ee the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.Data.SqlClient.SqlException: A network-related or instance-specific error occurred

while establishing a connection to SQL Server. The server was not found or was not

accessible. Verify that the instance name is correct and that SQL Server is configured to

allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a

connection to SQL Server)
at System.Data.SqlClient.SqlInternalConnection.OnErro r(SqlException exception,

Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndW arning(TdsParserStateObject

stateObj)
at System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo,

SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64

timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity,

SqlConnection owningObject)
at System.Data.SqlClient.SqlInternalConnectionTds.Att emptOneLogin(ServerInfo

serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64 timerExpire,

SqlConnection owningObject)
at System.Data.SqlClient.SqlInternalConnectionTds.Log inNoFailover(String host, String

newPassword, Boolean redirectedUserInstance, SqlConnection owningObject,

SqlConnectionString connectionOptions, Int64 timerStart)
at System.Data.SqlClient.SqlInternalConnectionTds.Ope nLoginEnlist(SqlConnection

owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean

redirectedUserInstance)
at System.Data.SqlClient.SqlInternalConnectionTds..ct or(DbConnectionPoolIdentity

identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword,

SqlConnection owningObject, Boolean redirectedUserInstance)
at System.Data.SqlClient.SqlConnectionFactory.CreateC onnection(DbConnectionOptions

options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection

owningConnection)
at System.Data.ProviderBase.DbConnectionFactory.Creat ePooledConnection

(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions

options)
at System.Data.ProviderBase.DbConnectionPool.CreateOb ject(DbConnection

owningObject)
at System.Data.ProviderBase.DbConnectionPool.UserCrea teRequest(DbConnection

owningObject)
at System.Data.ProviderBase.DbConnectionPool.GetConne ction(DbConnection

owningObject)
at System.Data.ProviderBase.DbConnectionFactory.GetCo nnection(DbConnection

owningConnection)
at System.Data.ProviderBase.DbConnectionClosed.OpenCo nnection(DbConnection

outerConnection, DbConnectionFactory connectionFactory)
at System.Data.SqlClient.SqlConnection.Open()
at System.Data.Common.DbDataAdapter.QuietOpen(IDbConn ection connection,

ConnectionState& originalState)
at System.Data.Common.DbDataAdapter.FillInternal(Data Set dataset, DataTable[]

datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand

command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32

maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable)
at WindowsFormsApplication3.Frm_Login.glassButton2_Cl ick(Object sender, EventArgs

e) in C:\Documents and Settings\Golden\My Documents\Visual Studio 2008

\Projects\WindowsFormsApplication3\WindowsFormsApp lication3\Frm_Login.cs:line 77
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventAr gs mevent)
at GlassButton.glassButton.OnMouseUp(MouseEventArgs mevent) in C:\Documents and

Settings\Golden\My Documents\Visual Studio 2008\Projects\WindowsFormsApplication3

\WindowsFormsApplication3\GlassButton.cs:line 340
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button,

Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.O nMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.W ndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr

wparam, IntPtr lparam)



خط 77

if (ds.Tables["t1"].Rows.Count > 0)
{
this.Hide();

loading fm11 = new loading();
fm11.ShowDialog();
}
else
{
MessageBox.Show("! " + "رمز عبور یا نام کاربری اشتباه می باشد", "!" + "اخطار", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.RightAlign);
}

و برای خط 340 ضمیمه شد.

Esmail Solhkhah
دوشنبه 14 شهریور 1390, 20:42 عصر
اگر اشتباه نکنم زود تر از سرویس SQL Server اجرا میشود.

نه سرویس SQL قبل از مرحله لود GUI ویندوز استارت میشه

اگه ممکنه کد کامل رو بذارید

ضمنا بنده متوجه نشدم GlassButton.rar‏ (http://barnamenevis.org/attachment.php?attachmentid=74905&d=1315237411) که ضمیمه کردید واسه چی بود.

Collector
دوشنبه 14 شهریور 1390, 23:03 عصر
نه سرویس SQL قبل از مرحله لود GUI ویندوز استارت میشه

اگه ممکنه کد کامل رو بذارید

ضمنا بنده متوجه نشدم GlassButton.rar‏ (http://barnamenevis.org/attachment.php?attachmentid=74905&d=1315237411) که ضمیمه کردید واسه چی بود.

از این WindowsFormsApplication3\GlassButton.cs:line 340 ایراد میگیرد.

Esmail Solhkhah
سه شنبه 15 شهریور 1390, 01:17 صبح
خود کنترل GlassButton موردی نداره

اگه احیانا داخل کد پروژه شما خطا میده، کد رو بزارید برا بررسی

موفق باشید.

Collector
سه شنبه 15 شهریور 1390, 12:33 عصر
خود کنترل GlassButton موردی نداره

اگه احیانا داخل کد پروژه شما خطا میده، کد رو بزارید برا بررسی

موفق باشید.

این کد مشکل SQL در استارت آپ دارد.

اگر زحمتی نیست از کنترل GlassButton هم استفاده کنید و مشکل آن را نیز بررسی کنید.

Esmail Solhkhah
سه شنبه 15 شهریور 1390, 18:45 عصر
این کد مشکل SQL در استارت آپ دارد.

بنده تست کردم موردی نداشت

زمانی که GUI ویندوز لود میشه ، برنامه شما هم همزمان اجرا میشه در این زمان هیچ کانکشنی به SQL SEVER نداره

وقتی کانکشن میزنه که کاربر دکمه Login رو زده باشه

Collector
سه شنبه 15 شهریور 1390, 19:15 عصر
بنده تست کردم موردی نداشت

زمانی که GUI ویندوز لود میشه ، برنامه شما هم همزمان اجرا میشه در این زمان هیچ کانکشنی به SQL SEVER نداره

وقتی کانکشن میزنه که کاربر دکمه Login رو زده باشه

موقعی که دکمه Login رو میزنم ارور میده مشکل چیه.

متن ارور


Timeout expired. The timeout period elapsed prior to completion of the
operation or the server is not responding.

ee the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.Data.SqlClient.SqlException: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
at System.Data.SqlClient.SqlInternalConnection.OnErro r(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndW arning(TdsParserStateObject stateObj)
at System.Data.SqlClient.TdsParserStateObject.ReadSni Error(TdsParserStateObject stateObj, UInt32 error)
at System.Data.SqlClient.TdsParserStateObject.ReadSni (DbAsyncResult asyncResult, TdsParserStateObject stateObj)
at System.Data.SqlClient.TdsParserStateObject.ReadNet workPacket()
at System.Data.SqlClient.TdsParserStateObject.ReadBuf fer()
at System.Data.SqlClient.TdsParserStateObject.ReadByt e()
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
at System.Data.SqlClient.SqlInternalConnectionTds.Com pleteLogin(Boolean enlistOK)
at System.Data.SqlClient.SqlInternalConnectionTds.Att emptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64 timerExpire, SqlConnection owningObject)
at System.Data.SqlClient.SqlInternalConnectionTds.Log inNoFailover(String host, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, Int64 timerStart)
at System.Data.SqlClient.SqlInternalConnectionTds.Ope nLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance)
at System.Data.SqlClient.SqlInternalConnectionTds..ct or(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance)
at System.Data.SqlClient.SqlConnectionFactory.CreateC onnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection)
at System.Data.ProviderBase.DbConnectionFactory.Creat ePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options)
at System.Data.ProviderBase.DbConnectionPool.CreateOb ject(DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionPool.UserCrea teRequest(DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionPool.GetConne ction(DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionFactory.GetCo nnection(DbConnection owningConnection)
at System.Data.ProviderBase.DbConnectionClosed.OpenCo nnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
at System.Data.SqlClient.SqlConnection.Open()
at System.Data.Common.DbDataAdapter.QuietOpen(IDbConn ection connection, ConnectionState& originalState)
at System.Data.Common.DbDataAdapter.FillInternal(Data Set dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable)
at WindowsFormsApplication7.Form1.button1_Click(Objec t sender, EventArgs e) in C:\Documents and Settings\Golden\Desktop\WindowsFormsApplication7\W indowsFormsApplication7\WindowsFormsApplication7\F orm1.cs:line 41
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventAr gs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.O nMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.W ndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

Esmail Solhkhah
سه شنبه 15 شهریور 1390, 19:39 عصر
کدتون رو بنده اجرا کردم موردی نداره

شما احتمالا با SQL SERVER که رو سیستمتون هست یه موردی دارید

برنامه های دیگتون هم خطای timeout میدن ؟

با فایل UDL تست کنید ببینید اونم خطای timeout میده

Collector
سه شنبه 15 شهریور 1390, 20:45 عصر
شما احتمالا با SQL SERVER که رو سیستمتون هست یه موردی دارید


دوست عزیز من کد لاگین رو به این صورت تغییر دادم. ولی این خطا را میدهد.

System.ServiceProcess.ServiceController sc = new System.ServiceProcess.ServiceController("MSSQL$SQLEXPRESS");

if (sc.Status.ToString() == "Running")
{
string s;
s = "select id from login where users='" + txt_User.Text + "' and id='" + txt_Pass.Text + "' ";
SqlDataAdapter da = new SqlDataAdapter(s, con);
da.Fill(ds, "t1");

if (ds.Tables["t1"].Rows.Count > 0)
{
this.Hide();

Form2 fm11 = new Form2();
fm11.ShowDialog();
}
else
{
MessageBox.Show("! " + "رمز عبور یا نام کاربری اشتباه می باشد", "!" + "اخطار", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.RightAlign);
}
}
else
{
MessageBox.Show("No Running");
sc.Start();
}

پیام خطا :

Cannot start service MSSQL$SQLEXPRESS on computer '.'.

See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.InvalidOperationException: Cannot start service MSSQL$SQLEXPRESS on computer '.'. ---> System.ComponentModel.Win32Exception: An instance of the service is already running
--- End of inner exception stack trace ---
at System.ServiceProcess.ServiceController.Start(Stri ng[] args)
at System.ServiceProcess.ServiceController.Start()
at WindowsFormsApplication7.Form1.button1_Click(Objec t sender, EventArgs e) in C:\Documents and Settings\Golden\Desktop\WindowsFormsApplication7\W indowsFormsApplication7\WindowsFormsApplication7\F orm1.cs:line 64
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventAr gs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.O nMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.W ndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

Esmail Solhkhah
چهارشنبه 16 شهریور 1390, 00:12 صبح
کد درسته

احتمالا کاربری که باهاش به ویندوز لاگین کردید مجوز تغییر وضعیت سرویس رو نداره