|
That did it - many thanks.
GER
Ger
|
|
|
|
|
Hi,
I was working a To-Do-List project. Notes adding to groups. Everything is fine, but, program not saves list in group view. Before restart program, list loading without groups. How to load with groups?
This is my code:
To Load List
On Error Resume Next
Dim FS = New System.IO.FileStream(AppDataFolder() & "\iNotes3\Me.int", IO.FileMode.Open)
lHeaders.Items.AddRange(BinFormatter.Deserialize(FS).ToArray(GetType(ListViewItem)))
FS.Close()
To Save List
On Error Resume Next
Dim FS As New System.IO.FileStream(AppDataFolder() & "\iNotes3\Me.int", IO.FileMode.Create)
BinFormatter.Serialize(FS, New ArrayList(lHeaders.Items))
FS.Close()
Add Note to List
Dim TodayDate As String
TodayDate = Date.Today
On Error Resume Next
If tHeader.Text = Nothing Then
tHeader.Select()
Else
Label1.Visible = False
lHeaders.Visible = True
Dim lvi As ListViewItem
lvi = lHeaders.Items.Add(tHeader.Text, 0)
lHeaders.Groups.Add(TodayDate.ToString, TodayDate)
lvi.Group = lHeaders.Groups(TodayDate.ToString)
lvi.UseItemStyleForSubItems = False
lvi.SubItems.Add(Date.Now, Color.Gray, Color.White, New System.Drawing.Font("Segoe UI", 8))
tHeader.Items.Add(tHeader.Text)
SaveHeaders()
End If
Thanks.
|
|
|
|
|
Hi,
I have used GDI+ Architect and I liked it for what it did.
I need to design a few A4 pages programmatically and need a WYSIWYG editor for it.
I downloaded GDI+ Architect from http://www.codeconfessions.com/[^] since mrgsoft.com is not working any more. But this version of the program seems to have some error when a saved file is opened again.
Does anyone have a working copy of it or suggest a free alternative for it?
Would appreciate any help
Som
|
|
|
|
|
If my C# code knows the name and path of a resource file in the solution explorer, I know how to read the resource file into a byte[] and then write it out somewhere else in the file system. In otherwords, export the resource file. But suppose all I know in code is the path to a folder in the solution explorer, for example Resources/InterestingFiles. How can I iterate through all the resource file names in that solution folder? If I could do that, I wouldn't need a hard-coded list of files embedded in my C# code, but could just iterate through a list of names and export all of them somewhere into the file system. I don't want a bunch of resource file names hard-coded in my C# code. I want a nice, tight loop where I can get one resource file name after another, something like the System.IO.Directory.GetFiles() static function within .NET that returns a string[] object containing all the file names within a directory.
modified on Saturday, April 3, 2010 6:08 AM
|
|
|
|
|
Hi,
When I tried to place files within a subfolder as you are suggesting they were not embedded into the assembly. Have you examined your assembly with a hex editor to see what you have in there?
Alan.
|
|
|
|
|
Alan N wrote: When I tried to place files within a subfolder as you are suggesting they were not embedded into the assembly.
I presume you set the resource file's Build Action to Embedded Resource, or at least Resource. If so, it will certainly be there.
Alan N wrote: Have you examined your assembly with a hex editor to see what you have in there?
Don't need to do that because I know they're there. I have a list of them embedded in the code and use the following code to successfully get at them and then export them to the file system:
Uri uri = new Uri("Resources/" + resourceFile, UriKind.Relative);
StreamResourceInfo sri = Application.GetResourceStream(uri);
Stream componentStream = sri.Stream;
I just don't want to have to remember to update that hard-coded list every time I add a new file to the Resources folder. It should be enough to put them into the folder through the solution explorer and set the Build Action to Resource. You shouldn't have to do anything more than that. My request in asking for help is, how can I pull out a list of relative paths so I can build the Uri for each embedded resource without hard coding the list in my C# code?
I've subsequently done a lot of sifting through MSDN on various classes such as Assembly, looking for something that would give me a collection of paths like Resources/InterestingFile but I haven't found anything that does the job.
|
|
|
|
|
Hi again,
Yes setting the build action to embedded resource does make a difference.
With the source file structure of
Resources (directory)
hidden (directory)
file1.txt
file2.txt
TfDll.dll
file3.txt
file4.txt
The following code
private void ShowResources2() {
Assembly a = Assembly.GetEntryAssembly();
foreach (String s in a.GetManifestResourceNames()) {
Console.WriteLine("NAME {0}", s);
if (s.Contains("TfDll.dll")) {
using (Stream rs = a.GetManifestResourceStream(s)) {
using (FileStream fs = File.Create("TfDll2.dll")) {
Byte[] buff = new Byte[8192];
Int32 read;
while ((read = rs.Read(buff, 0, buff.Length)) > 0) {
fs.Write(buff, 0, read);
}
}
}
}
}
}
outputs
NAME TfSync.MainForm.resources
NAME TfSync.Properties.Resources.resources
NAME TfSync.Resources.file3.txt
NAME TfSync.Resources.file4.txt
NAME TfSync.Resources.hidden.file1.txt
NAME TfSync.Resources.hidden.file2.txt
NAME TfSync.Resources.hidden.TfDll.dll
where TfSync and MainForm are the project's namespace and form. I also recreate an identical copy of TfDll.dll as TfDll2.dll.
Alan.
|
|
|
|
|
Thanks, Alan.
The reason my first attempt didn't work was because I had the Build Action of my resource files set to Resource and not Embedded Resource (an oversight on my part). When I made that change, The following code worked for me:
InstallationFiles = new List<string>();
Assembly a = Assembly.GetEntryAssembly();
foreach (String s in a.GetManifestResourceNames())
{
if (s.StartsWith("PHDInstallation.Resources."))
{
string fileName = s.Replace("PHDInstallation.Resources.", "");
InstallationFiles.Add(fileName);
}
}
|
|
|
|
|
|
Been there, done that. The array I got back had one entry in it: the path of my executable.
|
|
|
|
|
that does not fit the name of the method, nor my earlier experience with it.
I suggest you show actual code and give a detailed problem description.
|
|
|
|
|
Okay, my memory failed me slightly. It must have been one of my other experiments that returned the name of my executable. However, I did try the one you suggested and it didn't return anything obviously useful either. It returned the following two strings:
PhdBetaInstall.g.resources
PHDInstallation.Properties.Resources.resources
What am I supposed to do with those? I want strings returned like this:
Resources/InterestingFile1.dll
Resources/InterestingFile2.dll
etc. etc. To get those, I'd have two DLL's embedded with the specified names. Now maybe you can tell me what I'm supposed to do with the two strings that GetManifestResourceNames() did return that would produce what I want. But the MSDN reference you provided wasn't very helpful and I'd found it and tried it before starting this thread.
The code that produced the two strings from GetManifestResourceNames() is the following:
Assembly assembly = Assembly.GetExecutingAssembly();
string[] resourceNames = assembly.GetManifestResourceNames();
|
|
|
|
|
code such as:
Module module=type.Module;
Assembly assembly=module.Assembly;
log("Embedded resources for assembly "+assembly.ToString());
string[] sa=assembly.GetManifestResourceNames();
foreach (string s in sa) log(" "+s);
shows a list of embedded resources, i.e. data structures that reside inside an EXE or DLL (in this case the one holding the definition for Type type). The result could be:
Explorer.resources.winLP.jpg
Explorer.resources.LPExplorer.ico
Such information can be used like so to instantiate an object:
Bitmap bitmap=new Bitmap(type, resourceName);
Icon icon=new Icon(type, resourceName);
One way of getting such resources into your EXE/DLL file is by adding image/icon/whatever files to your solution, then setting their "Build Action" property to "Embedded Resource".
Your solution might contain other files as well, those would not become resources and not be listed by GetManifestResourceNames(). EXE and DLL files themselves are not considered resources. Also, you can add any file you want to a solution, even ones not needed for a successful build; and the resulting EXE/DLL typically does not know at all what files were used to get built.
|
|
|
|
|
Just a quick reply to this. I'll get back to a full response to your post later. I just want to note that it is precisely EXE and DLL files that I'm adding to my Resources folder that I want to export, because I'm "rolling my own" installation program, and the installation program has all the installation files of the application being installed embedded as resources so that I can distribute a single executable file that exports all the DLL and EXE files to the installation folder of the application being installed. So I'm not sure how this relates to this statement of yours. Perhaps you can elaborate:
Luc Pattyn wrote: EXE and DLL files themselves are not considered resources.
|
|
|
|
|
I use the following code :
mem.udt_PhonebyMemIDandContactType(memID, null, Txt_MobileNum.Text, null, 4, null);
the value of Txt_MobileNum.Text is unreachable because of the error "Cannot evaluate expression because a thread is stopped at a point where garbage collection is impossible, possibly because the code is optimized."
what is it for? what should i do?!!
|
|
|
|
|
you could Google your error message, which yields many including this one[^], it is a slow starter however the end looks interesting.
|
|
|
|
|
Hi Guys,
we've been running into some kind of strange trouble recnetly and not luck till now.
Ther error is coming only in one dev. machine out of 3. all have the same version of softwares and using TFS for version control.
For unit testing our modules containg NServiceBus code, we are using NServiceBus unit testing framework.
the code is like
<br />
[TestMethod]<br />
public void SomeMethod(Assembly asm)<br />
{<br />
...<br />
NServiceBus.Testing.Test.Initialize(asm);
...<br />
}<br />
the error message
Test method Decos.Kcs.UnitTests.Handlers.CaseHandlers.Dummy.AllCaseHandlerTest.TestSearchCaseHandler threw exception: System.BadImageFormatException: Could not load file or assembly 'file:///C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\devenv.exe' or one of its dependencies. The module was expected to contain an assembly manifest..
the stack trace is
System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)
System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)
System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
System.Reflection.Assembly.InternalLoadFrom(String assemblyFile, Evidence securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm, Boolean forIntrospection, StackCrawlMark& stackMark)
System.Reflection.Assembly.LoadFrom(String assemblyFile)
NServiceBus.Configure.GetTypesInDirectoryWithExtension(String path, String extension) in d:\BuildAgent-03\work\672d81652eaca4e1\src\config\NServiceBus.Config\Configure.cs: line 211
d__3.MoveNext() in d:\BuildAgent-03\work\672d81652eaca4e1\src\config\NServiceBus.Config\Configure.cs: line 173
ctor(IEnumerable`1 collection)
NServiceBus.Configure.With() in d:\BuildAgent-03\work\672d81652eaca4e1\src\config\NServiceBus.Config\Configure.cs: line 79
NServiceBus.Testing.Test.InitializeInternal() in d:\BuildAgent-03\work\672d81652eaca4e1\src\testing\Test.cs: line 38
NServiceBus.Testing.Test.Initialize(Assembly[] assemblies) in d:\BuildAgent-03\work\672d81652eaca4e1\src\testing\Test.cs: line 30
TResponseMessage]() in D:\Kanu\Projects\KCS\Sources\Decos.KCS\Development\Decos.Kcs.UnitTests.Handlers.CaseHandlers.Dummy\AllCaseHandlerTest.cs: line 102
Decos.Kcs.UnitTests.Handlers.CaseHandlers.Dummy.AllCaseHandlerTest.TestSearchCaseHandler() in D:\Kanu\Projects\KCS\Sources\Decos.KCS\Development\Decos.Kcs.UnitTests.Handlers.CaseHandlers.Dummy\AllCaseHandlerTest.cs: line 73
The output window contents on the error machine is
The Test.Initialize() methos fails on that specific machine.
While on other machine, it just does not look for devenv.exe.
It just continues with loading NServiceBus.Host and other dlls.
We have cross checked the referneces of the projects and everything seems to be fine.
any help is appreciated.
Thanks
|
|
|
|
|
tijujohn83 wrote: The output window contents on the error machine is
you may want to look into your post and possibly fix some HTML tag look-alikes.
|
|
|
|
|
Got the issue.
installed visual studio 2008 sp1 and it got fixed.
Thanks.
|
|
|
|
|
Suppose i am writing code in .net e.g
int i=10
then .net show me red line under the code where error occurs.we know the i have not apply semicolon at the end of syntax(int i=10;)
who handles these error while writing the source code???.
|
|
|
|
|
Visual Studio IDE
Arindam Banerjee
Sr. Software Developer
Rance Computer Pvt Ltd.
Kolkata (India)
|
|
|
|
|
Do not spam the forums. Pick one and stick with it.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
I am trying to create a bitmap after using capCreateCaptureWindow and capPreview. The video appears in the picture box but I can't seem to save the bitmap using capFileSaveDIB (which returns true after calling it - file does not appear in the directory).
I can successfully save the image to the clipboard but was not successfull in saving the contents to a bitmap.
I am using visual c++ 2008 express edition, and therefore have no MFC library.
Any suggestions would be greatly appreciated!
|
|
|
|
|
In my webpage iam having the text '2nd number of passcode' where this number is changing dynamically each time when the page loads. And based on this number we need to select the value from the combo box (having 0 to 9). Is there any way that we can get the number in that label so that i can assign the number respective to the combo box. (both label number and combo box number value remains same)
Is this possible in visual studio 2010 coded ui automation testing?
|
|
|
|
|
jaimo wrote: this number is changing dynamically each time when the page loads.
Where is it coming from? Magic?
jaimo wrote: Is there any way that we can get the number in that label
Ask the magician who created it.
I know the language. I've read a book. - _Madmatt
|
|
|
|