|
Oops, .NET 3.0
Johan Lombaard
Only two things are infinite, the universe and human stupidity, and I'm not sure about the former - Albert Einstein
|
|
|
|
|
You need to define the event with the associated event handler in XAML markup. VS 2005 (with WPF) wont automatically create an default event handler when you double click a control.
|
|
|
|
|
I have .NET 3.0 installed. I've not noticed any side-effects.
Kevin
|
|
|
|
|
I have an class library which uses Micrisoft Office Excel Object library for creating Excel objects. I want to include these dll's as a part of my class library dll. I tried using ILMerge utility, but could not merge these assemblies. Since Micrisoft.Office.Interop.Excel is a COM object I tried converting it into .Net assembly by using tlbImp. But am not able to do it. Please help in including it with my dll.
|
|
|
|
|
You can't. The client has to have Office installed in order to use this.
tlbImp doesn't convert anything to a .NET assembly. It creates a Runtime Callable Wrapper assembly that has to be used ALONG WITH the COM component. It will NOT replace the COM component.
|
|
|
|
|
Thanks a lot for the reply. I can understand that the client needs to have Excel installed on its machine. But I wish to use my library as a component so that the client may just add a reference to my dll and then call the required functions. For this to happen in current scenario the client will have to have the excel object library too in the bin folder.
|
|
|
|
|
jain.ashish21 wrote: For this to happen in current scenario the client will have to have the excel object library too in the bin folder.
Is that such a big deal?
|
|
|
|
|
Dear sirs:
I wrote program that performs one resource-intensive operation. This operation is to convert PDF into a text file. I decided to spin-off this single operation on a threading delegate as shown below:
Class Pdf()
{
public delegate string PdfIsbn();
string ISearch.Isbn( string sFileName )
{
m_sFileName = sFileName;
PdfIsbn pdfIsbn = new PdfIsbn( GetIsbn );
IAsyncResult iasResult = pdfIsbn.BeginInvoke( new AsyncCallback( IsbnComplete ) , "Isbn is complete" );
/**********************************
******** Regular Processing *******
**********************************/
// It only works if this code is un-commented.
while (!iasResult.IsCompleted)
{
Console.WriteLine("Please wait...");
//return m_sIsbn;
}
return m_sIsbn;
}
private void IsbnComplete( IAsyncResult iasResult )
{
AsyncResult ar = ( AsyncResult )iasResult;
PdfIsbn pdfIsbn = ( PdfIsbn )ar.AsyncDelegate;
m_sIsbn = pdfIsbn.EndInvoke( iasResult );
Constant.g_iThreadCount -= 1;
}
string GetIsbn()
{
Constant.g_iThreadCount += 1; // Increment thread-counter.
Console.WriteLine( "Pdf version of search implemented" );
Thread.Sleep(5000);
dtSearch dtSrch = new dtSearch( m_sFileName ); // Pass-in filename only.
regEx = new RegEx( "Isbn" ); // Search for a regular expression that fits the "ISBN"-type.
SearchIsbn( regEx , dtSrch.ResultText );
return m_sIsbn = regEx.RegExResult; // Get the ISBN.
}
}
The Main program is a windows form with a DataGridView. The main loop cycles through subfolders; each one containing a PDF.
do
{
try
{
file.GetDirectory(); // gets a book inside a directory, performs search etc.
// If a valid ISBN is found it will show up here.
if (file.SearchItem != "")
{
newBooks.AddBook(new Book(true, file.FileName, file.SearchItem));
}
}
catch (Exception ex)
{
file.LogError(ex, ex.Message.ToString());
}
} while ( file.SubFolder != "sub-folder iteration completed." ) ;
bindingSourceEbookCollection.DataSource = newBooks;
dataGridViewEbookCollection.DataSource = bindingSourceEbookCollection;
dataGridViewEbookCollection.AutoGenerateColumns = true;
I have tried to make the grid "aware" of all of the new book-entries being made inside the collection to which it is bound; to no avail.
I tried using a global "Thread Counter" so that the loop would keep executing until all the threads have been processed; and putting the "grid-binding" code inside the loop with the intent being that it would be "refreshed" with the new book-data.
The way the code is written now, the books show up but only after they have ALL been processed and the grid is blank until the whole process (all books) is completed.
The idea behind "encapsulating" the single, resource-intensive process inside a thread was to show the status of "processing... " inside the data grid for each book that was spun-off on a thread.
Any help is appreciated.
Many thanks,
R. Hyland
|
|
|
|
|
Maybe I am missing something here, but it seems like you should be updating your grid when the async event comes back:
private void IsbnComplete( IAsyncResult iasResult )
{
Then you need to do something like Application.DoEvents for your grid to repaint.
Hope that helps.
Ben
|
|
|
|
|
Thanks, I finally got it to work per your advice.
-- modified at 15:19 Thursday 24th May, 2007
|
|
|
|
|
I have old code written at VS 2003 which uses VS6/MFC.
When I try to run it at .Net 2.0 frame work, I got error ( I think a tone of MFC dll ).
Do you konw any links to solve it?
thanks!
|
|
|
|
|
Reli A. wrote: I have old code written at VS 2003 which uses VS6/MFC.
OK, so which is it, MFC7.1, or MFC6 ?
Reli A. wrote: When I try to run it at .Net 2.0 frame work, I got error ( I think a tone of MFC dll ).
You mean it blows up when it runs, or when it compiles ? If it builds in VS2005, it will link to the VS2005 dlls, I'd have thought. What errors are you getting ?
This question has nothing to do with the .NET framework, if you're talking about a C++/MFC app, so I'd ask it in the C++ forum.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
hellow to all
i am installing an app that i had wrote in win98 , that have all the framework updates ..
and every time i run the program i get this error
Application has generated an exception that could not be handled
process id=0xfff87f77 (-491657) , thread id=0xfff96927 (-431833)
|
|
|
|
|
So what did you do in your application that Windows 98 doesn't support? Did you EnableVisualStyles maybe? Or something else?
|
|
|
|
|
|
Hello!
Tell me please, how can I load pictures into WebBrowser control from the resources?
|
|
|
|
|
you can't directly - your web browser can only read HTML, with img tags which point to images on your hard drive, or on the network/internet.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Am I correct in assuming that if I have VS.NET 2005 installed and then put on the latest 3.0framework that I can still do projects that are NOT dependent on the V3.0 framework? I don't want to have to convert all my 2.0 projects over and I am not all that ready to start playing with all the cool V3.0 stuff just yet, I only want to start playing with the SCSF and the last build seems to require the update framework.
|
|
|
|
|
yes.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Thanks. I am not quite ready to delve into WPF just yet.
|
|
|
|
|
3.0 just adds to 2.0, in the same way that you can still use untyped collections in 2.0, but the new stuff is there, and better.
Yeah, I wish I had time for WPF, but I still don't, much.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
hey i'm creating a xaml browser application and I want to bind a database with a listbox in the interface ..does anyone has reference or an article that explains that??
I found an article but it's for windows apllications
|
|
|
|
|
It shouldn't really be much different than from windows apps, have you resolved this?
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
|
|
|
|
|
Hello,
This relates to my question yesterday, but this question is far more specific so I figured it best to start a new thread regarding it.
I am currently trying to design a method that will detect whether or not a folder is being actively copied to once it is detected by my application. For my program to function correctly, any detected folders in the target directory MUST be finished being copied to before my program can pick them up for processing. However, no matter what I try, my program tries to grab the folders and move them for processing before the copy is actually finished.
So far I've tried checking the LastWriteTime and LastAccessTime of the directory via the DirectoryInfo class. For some reason, these properties would state that the last write and access times were x seconds ago, even when the files were not completely done copying.
I thought this might be caused by files being written to subfolders inside the folder I was checking (which I'm assuming are not checked in reference to that particular top folder), so on a suggestion from Christian Graus, I tried a recursive script that would get the size of all files and folders inside the target folder and return that value. My program would use this method to first get the size of the folder, sleep the thread for a second, then recheck the value. If the values matched, the folder would be processed. If they didn't match, the folder was passed over and checked on the next cycle. However, even though the files were still not done copying (the file copy progress box was still showing), the cumulative directory size would be reported as the same on both checks and it would pick up the folder early again. I also checked the reported size value against the actual size of the folder (though the properties window in Windows) and the reported size matched the actual directory size, even though my program got that value while the files were still actively copying (once again, the file copy progress dialog was still visible and progressing).
So I'm really at a loss here. Does anyone know of a method to check a folder's activity and report whether files are still actually being copied to it? I've posted some of the relevant snippets, in case I just boffed my code and didn't realize it.
Thanks in advance for any assistance.
Code for getting folder size:
<br />
public static class Utility<br />
{<br />
public static int GetSize(DirectoryInfo dir)<br />
{<br />
int size = 0;<br />
foreach (FileInfo f in dir.GetFiles())<br />
{<br />
size += (int)f.Length;<br />
}<br />
foreach (DirectoryInfo d in dir.GetDirectories())<br />
{<br />
size += GetSize(d);<br />
}<br />
return size;<br />
}<br />
}<br />
Code for scraping the target directory and checking whether a folder is done being copied to or not (code relevant to this issue is bolded):
<br />
void RunAsyncScrape(object sender, DoWorkEventArgs e)<br />
{<br />
DirectoryInfo[] studies;<br />
try<br />
{<br />
studies = new DirectoryInfo(targetdir).GetDirectories();<br />
}<br />
catch (Exception ex)<br />
{<br />
MessageBox.Show("Could not scrape the target directory\nReason: " + ex.Message, "File Scraping Error");<br />
}<br />
<br />
if (studies.Length > 0)<br />
{<br />
ArrayList orders = new ArrayList();<br />
foreach (DirectoryInfo dir in studies)<br />
{<br />
int size = Utility.GetSize(dir);<br />
Thread.Sleep(1000);<br />
int sizeb = Utility.GetSize(dir);<br />
if (size == sizeb)<br />
{<br />
orders.Add(dir)<br />
}<br />
}<br />
if (orders.Count > 0)<br />
e.Result = orders;<br />
}<br />
}<br />
|
|
|
|
|
Christoff915 wrote: So far I've tried checking the LastWriteTime and LastAccessTime of the directory via the DirectoryInfo class. For some reason, these properties would state that the last write and access times were x seconds ago, even when the files were not completely done copying.
This is true. The reason is because NTFS only updates those properties every once in while. It does NOT do it on-the-fly as the file is being written to. So, the file WAS written to at that time. It doesn't mean that the file write has stopped yet.
Christoff915 wrote: I thought this might be caused by files being written to subfolders inside the folder I was checking (which I'm assuming are not checked in reference to that particular top folder), so on a suggestion from Christian Graus, I tried a recursive script that would get the size of all files and folders inside the target folder and return that value. My program would use this method to first get the size of the folder, sleep the thread for a second, then recheck the value. If the values matched, the folder would be processed. If they didn't match, the folder was passed over and checked on the next cycle. However, even though the files were still not done copying (the file copy progress box was still showing), the cumulative directory size would be reported as the same on both checks and it would pick up the folder early again. I also checked the reported size value against the actual size of the folder (though the properties window in Windows) and the reported size matched the actual directory size, even though my program got that value while the files were still actively copying (once again, the file copy progress dialog was still visible and progressing).
Again, you're checking this information faster than NTFS updates it! NTFS is LAZY. You cannot depend on the properties to tell you when the folder is finished.
You can't check this every second to see if it's done. You're simply not going to know unless the application that is writing the data tells you. Somehow, I doubt that it has any such capability.
Since the app can't tell you when it's done, you're only semi-reliable method is to check for the existance of the folder and get it's total size, about once every 15 seconds, and KEEP DOING THIS! If the size doesn't change for, say, the last 3 passes, then you can assume the app is done writing to the folder.
Note, I said "assume". Because of system failures or loads, or whatnot, there is no absolutely 100% reliable method of knowing when the other app is done. THe only way that's going to happen is if the other app tells you it's done.
|
|
|
|