|
If it's freezing the UI, then it's probably because the file wipe is taking a considerable amount of time - and because it's all being done in the same thread, the UI can't update until the long running task is complete.
Move your Wipe into a different thread and it should "unfreeze" the UI. Have a look at the BackgroundWorker class[^] - it's easy to use and provides event for progress reportign and task completion.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
1. You need to call StartWipeFile() on a different thread.
2. When posting, check that you don't mis-paste the code - such as showing & quot; etc.
3. Do a little debugging yourself - just clicking the "Break into debug" would have shown you the problem
Best,
John
|
|
|
|
|
Hello All exoperts,
below code which I saw in code project wi;l;l do a pivot of a data set where x,y,z axis are fixed, I just want to have 4 column to be used as y axis , can I do that ?
what I understood frpom the code,
y axis value is stored in a ;list
List<string> columnYValues = new List<string>();
and it was return at
foreach (string columnYValue in columnYValues)
{
//Creates a new Row
DataRow drReturn = returnTable.NewRow();
drReturn[0] = columnYValue;
can I return other y axis cpo;lumn in same way with in the same ;loop\.
///
/// Gets a Inverted DataTable
///
/// <param name="table" />Provided DataTable
/// <param name="columnX" />X Axis Column
/// <param name="columnY" />Y Axis Column
/// <param name="columnZ" />Z Axis Column (values)
/// <param name="columnsToIgnore" />Whether to ignore some column, it must be
/// provided here
public static DataTable GetInversedDataTable(DataTable table, string columnX,
string columnY, string columnZ, string nullValue, bool sumValues)
{
//Create a DataTable to Return
DataTable returnTable = new DataTable();
if (columnX == "")
columnX = table.Columns[0].ColumnName;
//Add a Column at the beginning of the table
returnTable.Columns.Add(columnY);
//Read all DISTINCT values from columnX Column in the provided DataTale
List<string> columnXValues = new List<string>();
foreach (DataRow dr in table.Rows)
{
string columnXTemp = dr[columnX].ToString();
if (!columnXValues.Contains(columnXTemp))
{
//Read each row value, if it's different from others provided, add to
//the list of values and creates a new Column with its value.
columnXValues.Add(columnXTemp);
returnTable.Columns.Add(columnXTemp);
}
}
//Verify if Y and Z Axis columns re provided
if (columnY != "" && columnZ != "")
{
//Read DISTINCT Values for Y Axis Column
List<string> columnYValues = new List<string>();
foreach (DataRow dr in table.Rows)
{
if (!columnYValues.Contains(dr[columnY].ToString()))
columnYValues.Add(dr[columnY].ToString());
}
//Loop all Column Y Distinct Value
foreach (string columnYValue in columnYValues)
{
//Creates a new Row
DataRow drReturn = returnTable.NewRow();
drReturn[0] = columnYValue;
//foreach column Y value, The rows are selected distincted
DataRow[] rows = table.Select(columnY + "='" + columnYValue + "'");
//Read each row to fill the DataTable
foreach (DataRow dr in rows)
{
string rowColumnTitle = dr[columnX].ToString();
//Read each column to fill the DataTable
foreach (DataColumn dc in returnTable.Columns)
{
if (dc.ColumnName == rowColumnTitle)
{
//If Sum of Values is True it try to perform a Sum
//If sum is not possible due to value types, the value
// displayed is the last one read
if (sumValues)
{
try
{
drReturn[rowColumnTitle] =
Convert.ToDecimal(drReturn[rowColumnTitle]) +
Convert.ToDecimal(dr[columnZ]);
}
catch
{
drReturn[rowColumnTitle] = dr[columnZ];
}
}
else
{
drReturn[rowColumnTitle] = dr[columnZ];
}
}
}
}
returnTable.Rows.Add(drReturn);
}
}
else
{
throw new Exception("The columns to perform inversion are not provided");
}
//if a nullValue is provided, fill the datable with it
if (nullValue != "")
{
foreach (DataRow dr in returnTable.Rows)
{
foreach (DataColumn dc in returnTable.Columns)
{
if (dr[dc.ColumnName].ToString() == "")
dr[dc.ColumnName] = nullValue;
}
}
}
return returnTable;
}
|
|
|
|
|
If you got the code from an article, then there is a "Add a Comment or Question" button at the bottom of that article, which causes an email to be sent to the author. They are then alerted that you wish to speak to them.
Posting this here relies on them "dropping by" and realising it is for them.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Member 12061647 wrote: below code which I saw in code project Please post your question in the forum at the end of the article so the author can help you.
|
|
|
|
|
I have a Hm-tr module and i want to observe it output in a box
I connect it to my pc and i want observe the data that has been received in my pc. it is important that the program writen with c# but if u have any other idea,tell me.
tnk a lot.
|
|
|
|
|
|
|
Context.InvokeAsynchronousTask(() =>
{
});
I have this code, its not getting called from the unit test project.
|
|
|
|
|
Well, without seeing the code for the unit test project, how do you expect anyone to give you any kind of usable answer?
|
|
|
|
|
Most likely the test finishes before the asynchronous task has a chance to execute.
You'll have to wait in the test for the completion of the asynchronous task. If you don't have a callback method that gets executed on completion you might just have to wait a few moments.
I usually use the ManualResetEvent with the WaitOne Method for such cases.
You can specify a timeout after which the execution should continue even if you don't receive a signal.
|
|
|
|
|
Thanks a lot
|
|
|
|
|
I am using WPF TestBlock control and activating a font which family id is Adolescence using Win32 API AddFontResource. This font is available on various document and also can be easily usable just adding the familyname on html web control. But for WPF TextBox it is not working just passing the family name.
I am using following code snippet.
<TextBlock Grid.Row="0" x:Name="SampleText" Text="{Binding
SampleText}" FontFamily="Adolescence" FontStyle="Normal"
FontSize="20"/>
I cannot put our fonts into windows font directory and also cannot add the directory path in FontFamily parameter and cannot add font into package.
I did googling a lot but could not found any solution. I also very curious to know why WPF is application is not able to detect Font while other application is able to detect the same.
Thanks in advance.
|
|
|
|
|
|
Some apps will "infer" a font based on a "name" and some properties; e.g. "Myriad Pro" and italic weight gives "Myriad Pro Italic", etc.
WPF needs the exact font name.
You should check the names of the fonts in the Control Panel "Fonts" app.
There are fonts (indicated with a little "stack" icon) that when clicked in Control Panel will yield other "sub-fonts" (which names one would use in WPF; besides the font properties).
|
|
|
|
|
<connectionstrings>
<add name="CostAllocationEntities2"
="" connectionstring="Data Source=PC210090\SQLEXPRESS;initial catalog=testdb1;Persist Security Info=True;User ID=sa;Password=password1$" providername="System.Data.SqlClient">
SqlConnection conn;
public SqlConnection openconn()
{
conn = new SqlConnection(ConfigurationManager.ConnectionStrings["CostAllocationEntities2"].ConnectionString);
try
{
if (conn.State == ConnectionState.Closed)
{<br />
conn.Open();
return conn;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString(), "Failed to Connect with Database.", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return null;
}
return conn;
}
public void GetBackup(string strDBName)
{
if (string.IsNullOrEmpty(strDBName))
{
MessageBox.Show("Server Name & Database can not be Blank");
return;
}
else
{
string destinationPath = ConfigurationManager.AppSettings.Get("BackupDestinationPath");
BackupDeviceItem deviceItem = new BackupDeviceItem(destinationPath, DeviceType.File);
ServerConnection connection = new ServerConnection(ConfigurationManager.ConnectionStrings["CostAllocationEntities2"].ConnectionString);
Server sqlServer = new Server(connection);
Database db = sqlServer.Databases[strDBName];
Backup bkpDBFull = new Backup();
bkpDBFull.Action = BackupActionType.Database;
bkpDBFull.Database = strDBName;<br />
bkpDBFull.Devices.AddDevice(String.Format("{0}{1}-{2}.bak", destinationPath, strDBName, DateTime.Now.ToString("yyyy-MM-dd")), DeviceType.File);
bkpDBFull.BackupSetName = strDBName + " Backup";
bkpDBFull.BackupSetDescription = strDBName + "- Full Backup";
bkpDBFull.ExpirationDate = DateTime.Today.AddDays(10);<br />
bkpDBFull.Initialize = false;
bkpDBFull.SqlBackup(sqlServer);
MessageBox.Show("Backup Done");
}
}
On this line
Database db = sqlServer.Databases[strDBName];
I get an error:
Not allowed to change the 'ConnectionString' property. The connection's current state is connecting."
-- modified 28-Oct-15 2:27am.
|
|
|
|
|
|
Hello guys/gals,
Since a few months i have rather a real head desturbing issue :/
I have developed a plugin architecture that exists of a Host app and several plugins.
The host app basicly loads all the plugins availible, and allows any plugin to interact with the host, and vice versa.
Everything works fine when it comes to using methods/properties ect...accept for the events...
The events are used to send info to any asigned instance, including the plugins.
Whenever i assign the event inside plugin to recieve info from the host then i get the 'System.Reflection.TargetInvocationException'.
The exception is thrown whenever the host invokes the event that has been assigned from plugin instance.
Though i should mention that the event is used by the plugin AND the host.
They both should be revieving the plugin info...
I know ive used several events in a plugin system before, but that was the other way around.
The host was recieving info from plugin , witch works, just the other way arround seems to be a issue.
The Plugins are loaded by system.reflection as raw data and not as a file...
i did this because the plugins are stored in a custom container, compressed and encrypted.
Here is the manager interface (HOST):
public interface IPluginManager : IPluginBase
{
bool IsLoaded { get; }
Settings AppPreferences { get; }
ILogin Server { get; }
byte[] Signature { get; }
AppInfo[] Plugins { get; }
#region Events
event PluginRequestHandler PluginUpdate;
event PluginRequestHandler PluginInstall;
event PluginRequestHandler PluginRemove;
event PluginInstallHandler PluginsToInstall;
event PluginInstallHandler PluginsToUpdate;
event PluginInstallHandler PluginsToRemove;
event PluginHandler PluginActionChanged;
event PluginsHandler PluginsInstalled;
event PluginsHandler PluginsUpdated;
event PluginsHandler PluginsRemoved;
event EventHandler ManagerLoaded;
event EventHandler ManagerLoading;
event EventHandler ManagerDisposed;
#endregion
#region Methods
void LoadAsync();
void Dispose();
void RemovePluginAsync(AppInfo plugin);
bool RemovePlugin(AppInfo plugin);
void InstallPluginAsync(AppInfo plugin);
bool InstallPlugin(AppInfo plugin);
bool InstallNewPlugins();
void InstallNewPluginsAsync();
void MountPluginAsync(AppInfo info);
void UnmountPluginAsync(AppInfo info);
void EnableApp(AppInfo info);
void DisableApp(AppInfo info);
AppInfo[] GetOnlineApps();
#endregion
}
Here the code from plugin instance that init the Host event.
private void MainForm_Shown(object sender, EventArgs e)
{
if (Host != null && Host.PluginManager != null)
{
SCManager = Host.PluginManager;
SCManager.PluginActionChanged += X_PluginActionChanged;
Server = SCManager.Server;
if (Server == null)
{
var x = SCManager.Plugins.FirstOrDefault(t => t.Type == 1);
if (x != null)
SCManager.MountPluginAsync(x);
}
}
OnWindowShown(this);
}
Here is the Code that triggers the event:
protected virtual void OnPluginActionChanged(AppInfo info,PluginActionType action,Exception error = null,object param = null)
{
PluginHandler handler;
lock (_eventlock)
handler = _PluginActionChanged;
handler?.Invoke(this, info, action, error,param);
}
I really hope someone inhere can point me to the right direction, as i'm totally lost...
Thanks! and sorry for my bad english, let me know please if you guys/gals have any more question.
|
|
|
|
|
A TargetInvocationException occurs when an exception is thrown from a constructor. The stacktrace should show where it is trying to create the object that blows.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
MSDN says "The exception that is thrown by methods invoked through reflection. This class cannot be inherited."
so my take is that the issue occurs exactly at the
?.Invoke call.
What I don't understand is why the original poster doesn't just debug the code, and set the debugger to break on all exceptions - easy peasy.
The Plugins are loaded by system.reflection as raw data and not as a file...
i did this because the plugins are stored in a custom container, compressed and encrypted.
This sounds unnecessarily complicated - but I would first test uncompressing/decrypting them first, then go one step at a time, see when the issue occurs.
Best,
John
|
|
|
|
|
John Torjo wrote: MSDN says ..and so begins my favorite line of argumenting.
Upvoted
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Hi,
I have a WinForm C# application which works perfet on my laptop but when I installed on on another it';s crashing and not throwing any error. When I checked the Windows EventLog I found below errors but can't understand where is the issue and what IO Fle is missing? Can anyone help please..
Thanks,
Jassim[^]
Log Name: Application
Source: Application Error
Date: 27-Oct-15 11:59:36 AM
Event ID: 1000
Task Category: (100)
Level: Error
Keywords: Classic
User: N/A
Computer: AUDITOR
Description:
Faulting application name: TrueAsset.exe, version: 1.0.0.0, time stamp: 0x561e711d
Faulting module name: KERNELBASE.dll, version: 6.2.9200.16384, time stamp: 0x5010ab2d
Exception code: 0xe0434352
Fault offset: 0x00000000000189cc
Faulting process ID: 0x12e0
Faulting application start time: 0x01d11095ce59ce4c
Faulting application path: C:\Program Files (x86)\TrueAsset\TrueAsset\TrueAsset.exe
Faulting module path: C:\Windows\system32\KERNELBASE.dll
Report ID: 0c124612-7c89-11e5-befb-50b7c3624f32
Faulting package full name:
Faulting package-relative application ID:
Event Xml:
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
<System>
<Provider Name="Application Error" />
<EventID Qualifiers="0">1000</EventID>
<Level>2</Level>
<Task>100</Task>
<Keywords>0x80000000000000</Keywords>
<TimeCreated SystemTime="2015-10-27T08:59:36.000000000Z" />
<EventRecordID>66461</EventRecordID>
<Channel>Application</Channel>
<Computer>AUDITOR</Computer>
<Security />
</System>
<EventData>
<Data>TrueAsset.exe</Data>
<Data>1.0.0.0</Data>
<Data>561e711d</Data>
<Data>KERNELBASE.dll</Data>
<Data>6.2.9200.16384</Data>
<Data>5010ab2d</Data>
<Data>e0434352</Data>
<Data>00000000000189cc</Data>
<Data>12e0</Data>
<Data>01d11095ce59ce4c</Data>
<Data>C:\Program Files (x86)\TrueAsset\TrueAsset\TrueAsset.exe</Data>
<Data>C:\Windows\system32\KERNELBASE.dll</Data>
<Data>0c124612-7c89-11e5-befb-50b7c3624f32</Data>
<Data>
</Data>
<Data>
</Data>
</EventData>
</Event>
Log Name: Application
Source: .NET Runtime
Date: 27-Oct-15 11:59:36 AM
Event ID: 1026
Task Category: None
Level: Error
Keywords: Classic
User: N/A
Computer: AUDITOR
Description:
Application: TrueAsset.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.IO.FileNotFoundException
Stack:
at Inventory_Management_System.Program.Main()
Event Xml:
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
<System>
<Provider Name=".NET Runtime" />
<EventID Qualifiers="0">1026</EventID>
<Level>2</Level>
<Task>0</Task>
<Keywords>0x80000000000000</Keywords>
<TimeCreated SystemTime="2015-10-27T08:59:36.000000000Z" />
<EventRecordID>66460</EventRecordID>
<Channel>Application</Channel>
<Computer>AUDITOR</Computer>
<Security />
</System>
<EventData>
<Data>Application: TrueAsset.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.IO.FileNotFoundException
Stack:
at Inventory_Management_System.Program.Main()
</Data>
</EventData>
</Event>
Technology News @ www.JassimRahma.com
|
|
|
|
|
Well, as we have no idea at all what files your application is using, there's no possible way we can answer this. What I would suggest is that you add unhandled exception handling at the top of your application (e.g. AppDomain.UnhandledException or Application.ThreadException ). Log in here, the trace of where your code failed.
|
|
|
|
|
Probably your app depends on a DLL that is not signed properly (maybe delay-signed?)
But yeah, we'd definitely need more info to give you a more informed answer.
Best,
John
|
|
|
|
|
Well, in your second event log there is a FileNotFoundException in your Main method, so there's a start.
It's impossible to be any more specific with the information you've given.
|
|
|
|