25 new messages in 12 topics - digest

== 1 of 4 ==
Date: Fri, May 9 2008 9:31 pm
From: "Peter Duniho"


On Fri, 09 May 2008 20:59:27 -0700, Jeff <jeff@[_nospam_].hardsoft.com.au>
wrote:

> I need a way to do the following and cannot seem to find a solution via
> google.
>
> 1. Have a method from the main app to get all open forms
> 2. Check each open form for a public method
> 3. If this public method exists execute it which will result in the
> displayed form being updated.  There will be no data loss as the forms
> will only contain listviews or readonly fields.

I don't really understand the last statement, as neither the question of
ListView instances or of readonly fields affects whether there could
potentially be data loss.

However, to address your specific question, you are looking for the
Reflection namespace.  You can use GetType() on each form instance to get
its actual type, and then use that Type instance to look for particular
members, including a method to invoke.

That said, using Reflection should be a last resort.  As an example here,
it would be much better if each form that might need this method to be
called instead implemented the method as an event handler.  Then the
application would define an event each form could subscribe to.  When the
event was raised, each form would then have its method executed
automatically, without having to go through all the reflection rigamarole.

If for some reason that and any other potential alternative isn't
possible, then reflection is your answer.

Pete




== 2 of 4 ==
Date: Fri, May 9 2008 11:10 pm
From: Jeff


Thanks Peter

Something new for me to learn and try.

This opens up something I did not know you could do and it seams that
events can be across applications and one application can fire an even
in another if they are both subscribed.

Now to find a good article and sample code.

Jeff

Peter Duniho wrote:
> On Fri, 09 May 2008 20:59:27 -0700, Jeff
> <jeff@[_nospam_].hardsoft.com.au> wrote:
>
>> I need a way to do the following and cannot seem to find a solution
>> via google.
>>
>> 1. Have a method from the main app to get all open forms
>> 2. Check each open form for a public method
>> 3. If this public method exists execute it which will result in the
>> displayed form being updated.  There will be no data loss as the forms
>> will only contain listviews or readonly fields.
>
> I don't really understand the last statement, as neither the question of
> ListView instances or of readonly fields affects whether there could
> potentially be data loss.
>
> However, to address your specific question, you are looking for the
> Reflection namespace.  You can use GetType() on each form instance to
> get its actual type, and then use that Type instance to look for
> particular members, including a method to invoke.
>
> That said, using Reflection should be a last resort.  As an example
> here, it would be much better if each form that might need this method
> to be called instead implemented the method as an event handler.  Then
> the application would define an event each form could subscribe to.
> When the event was raised, each form would then have its method executed
> automatically, without having to go through all the reflection rigamarole.
>
> If for some reason that and any other potential alternative isn't
> possible, then reflection is your answer.
>
> Pete




== 3 of 4 ==
Date: Sat, May 10 2008 12:53 am
From: "Peter Duniho"


On Fri, 09 May 2008 23:10:40 -0700, Jeff <jeff@[_nospam_].hardsoft.com.au>
wrote:

> This opens up something I did not know you could do and it seams that
> events can be across applications and one application can fire an even
> in another if they are both subscribed.

Well, when I wrote "event" I was speaking of the .NET/C# variety of
events.  The unmanaged Windows API also has the concept of "events", but
they aren't subscription based, and while named events can be
cross-application (i.e. cross-process), they are only useful for
communicating a toggle state.

There was nothing in your original question that suggested you needed a
cross-process solution.  If you do, then neither reflection nor a C# event
will help.

If you don't need a cross-process solution, then you may want to start
here:
http://msdn.microsoft.com/en-us/library/8627sbea.aspx [event (C#
Reference)]

Be sure to visit this page too:
http://msdn.microsoft.com/en-us/library/awbftdfh.aspx [Events (C#
Programming Guide)]

It contains lots of links to additional useful articles on the topic.

Pete




== 4 of 4 ==
Date: Sat, May 10 2008 10:16 am
From: "Nathan"


Maybe I'm misunderstanding you, but it sounds like using an interface would
be the easiest solution.  Require all your forms to implement an interface
with that method defined; then you can loop through all the forms and call
that method on each.

"Jeff" <jeff@[_nospam_].hardsoft.com.au> wrote in message
news:tN2dnUuKAM0_gLjVnZ2dnUVZ_obinZ2d@posted.internode...
>I need a way to do the following and cannot seem to find a solution via
>google.
>
> 1. Have a method from the main app to get all open forms
> 2. Check each open form for a public method
> 3. If this public method exists execute it which will result in the
> displayed form being updated.  There will be no data loss as the forms
> will only contain listviews or readonly fields.
>
> Regards
> Jeff






==============================================================================
TOPIC: C# plans towards metaprogramming
http://groups.google.com/group/microsoft.public.dotnet.languages.csharp/browse_thread/thread/64e153216222ff82?hl=en
==============================================================================

== 1 of 1 ==
Date: Fri, May 9 2008 10:55 pm
From: "Anders Borum"


I'm just after variance in return types - that's it. I'd recommend looking
at Jon Skeets blog also for additional requests to C#.

--
With regards
Anders Borum / SphereWorks
Microsoft Certified Professional (.NET MCP)






==============================================================================
TOPIC: VS2008 and Webservice
http://groups.google.com/group/microsoft.public.dotnet.languages.csharp/browse_thread/thread/d08303ec909cf56e?hl=en
==============================================================================

== 1 of 6 ==
Date: Sat, May 10 2008 2:17 am
From: bob


Hi,
I am trying to develop a webservice and an aspx client on a Win2003
server box. The IDE is VS2008.
The thing just seems totally flaky.
Webservice compiles and publishes with no errors.
Access the Service with http://localhost:2092/EasyVend0r.asmx (Note
using the port assigned by the IDE)
and no problem.

But start a browser and go to access the ASMX with the published URL
of http:localhost//EasyVend0r.asmx and you get
Parser Error Message: Could not create type 'EasyVend0r.EasyVend0r'.

Source Error:

Line 1:  <%@ WebService Language="C#" CodeBehind="EasyVend0r.asmx.cs"
Class="EasyVend0r.EasyVend0r" %>

Getting similar errors when trying to access the aspx client page.

Basically as long as you stay in the IDE or use the port that the IDE
has assigned  you can view the asmx and aspx
Go outside and the wheels fall off.

I am not a web developer so I am probably missing some fundamental
step.

But it is annoying that everything seems to deploy OK according to the
IDE but the browser is unhappy with the 'published' i.e. Unspecified
port result.
I don't remember grief like this with VS2005
Any clues as to what I am doing wrong?

Thanks
Bob




== 2 of 6 ==
Date: Sat, May 10 2008 2:43 am
From: henk holterman


bob wrote:

> Webservice compiles and publishes with no errors.
> Access the Service with http://localhost:2092/EasyVend0r.asmx (Note
> using the port assigned by the IDE)
> and no problem.
>
> But start a browser and go to access the ASMX with the published URL
> of http:localhost//EasyVend0r.asmx and you get
> Parser Error Message: Could not create type 'EasyVend0r.EasyVend0r'.
 > [...]
> Line 1:  <%@ WebService Language="C#" CodeBehind="EasyVend0r.asmx.cs"
> Class="EasyVend0r.EasyVend0r" %>

Bob, when you run from the IDE you are using the built-in webserver
(Cassini), on a selected port.

When you use /localhost/ , without a port, you must be using a virtual
directory on the installed server (IE) on your PC.

Apparently you did not correctly publish the entire webservice to this
virtual directory. Try using the Publish_Website option from the IDE.

It also looks like you are using the root virtual dir, that may not be
wise. Be aware that the Publish tool will "clean" it's target folder.

-HH-







== 3 of 6 ==
Date: Sat, May 10 2008 2:48 am
From: henk holterman


bob wrote:

> Webservice compiles and publishes with no errors.
> Access the Service with http://localhost:2092/EasyVend0r.asmx (Note
> using the port assigned by the IDE)
> and no problem.
>
> But start a browser and go to access the ASMX with the published URL
> of http:localhost//EasyVend0r.asmx and you get
> Parser Error Message: Could not create type 'EasyVend0r.EasyVend0r'.


Bob, when you run from the IDE you are using the built-in webserver
(Cassini), on a selected port.

When you use /localhost/ , without a port, you must be using a virtual
directory on the installed server (IIS) on your PC.

Apparently you did not correctly publish the entire webservice to this
virtual directory. Try using the Publish_Website option from the IDE.

It also looks like you are using the root virtual dir, that may not be
wise. Be aware that the Publish tool will "clean" it's target folder.

-HH-




== 4 of 6 ==
Date: Sat, May 10 2008 3:36 am
From: Marc Gravell


Have you configured the target directory (in IIS or whatever) to run
as an application? You need to do this manually, otherwise the "app"
will be at the wrong folder, and the "bin" folder won't be used, so
your types don't exist.

This is usually the problem with this error message...




== 5 of 6 ==
Date: Sat, May 10 2008 12:51 pm
From: bob


Hi Henk and Marc
Thank you for your replies.
I now know where to look.

It seems to me  we still have a way to go with Web deployment.
Ironic given that the Dot net movement started with the Web in mind.

When a dumb bunny like me  pushes a publish button and gets led
through a wizard that completes successfully,  they are entitled to
expect that no specialised additional knowledge is required to
'really' publish.

regards
Bob






== 6 of 6 ==
Date: Sat, May 10 2008 2:43 pm
From: Marc Gravell


> Ironic given that the Dot net movement started with the Web in mind.

Well, it (a better ASP via ASP.NET) was certainly a consideration -
but it was far from the only aim... another goal was to be a better
COM/COM+, regardless of *what* it was doing...

Note that "web deployment projects" almost certainly configure IIS
like this.





==============================================================================
TOPIC: simple logging in a C# COM DLL
http://groups.google.com/group/microsoft.public.dotnet.languages.csharp/browse_thread/thread/9b40554d5d28f69f?hl=en
==============================================================================

== 1 of 1 ==
Date: Sat, May 10 2008 2:47 am
From: wurzelCidermaker



So are you saying that a DLL cannot read a [myDll.dll.config] automatcially
and add a trace listener contained in that config file?

"Ignacio Machin ( .NET/ C# MVP )" wrote:

> On May 9, 12:51 pm, wurzelCidermaker
> <wurzelCiderma...@discussions.microsoft.com> wrote:
> > I have created a very simple C# class library (DLL).
> >
> > I have ticked the "Register for COM interop" option in the project
> > properties dialog.
> >
> > I have made the [assembly: ComVisible(true)] in the AssemblyInfo.cs file.
> >
> > I can call a public method in this library from VBScript.
> >
> > So far so good, now I'd like to have some very *simple* loggging capability.
> >
> > For other applications I've gone down the [log4net] route and rolled by own
> > loggers etc...etc.
> >
> > For this tiny DLL, I'd like to have for example the option to just drop a
> > [myDll.dll.config] file into the same directory as the DLL and add a trace
> > listener that outputs to a file or optionally roll my own trace listener
> > (i.e. udp).
> >
> > I've successfully done things with trace listeners, but cannot get the DLL
> > to pick up the custom trace listener config file.
> >
> > I've tried various names for the config file, but no joy.
> >
> > Any suggestions?
> >
> > Is it because I'm calling it from a VBScript file and not a .NET application?
>
> Hi,
>
> By default a DLL has no config file. What you can do is read the
> config in your code , make the file to reside in the same folder of
> the dll, then you can read it using something like
> System.IO.Path.GetDirectoryName( Assembly.GetRunningAssembly().Location)
> + "\\log.config";
>





==============================================================================
TOPIC: Problem about getting a excel datasheet's name with oledb
http://groups.google.com/group/microsoft.public.dotnet.languages.csharp/browse_thread/thread/f9382902425de048?hl=en
==============================================================================

== 1 of 1 ==
Date: Sat, May 10 2008 7:17 am
From: Kun Niu


Thanks.
I'll pay attention to that.:)

"mario.ivic2@gmail.com" wrote:

> On May 5, 6:06 pm, Kun Niu <Kun...@discussions.microsoft.com> wrote:
> > Dear all,
> >
> > I'm trying to use oledb to get the content of an excel file.
> > Now I can use oledb to get the content of a datasheet.
> > But I should know the name of the datasheet in advance.
> > How can I use oledb to query the names of all the spreadsheets in the excel
> > file?
> >
> > Thanks in advance for any hints and reply.
>
> Hi,
>
> You can use Excel Automation or some third party component -- it works
> much better. I can recommend you to use GemBox.Spreadsheet .NET
> component.
>
> --
> Mario
> GemBox.Spreadsheet for .NET - Easily read and write Excel (XLS, XLSX
> or CSV) files or export to HTML files from your .NET apps. See
> http://www.gemboxsoftware.com/GBSpreadsheet.htm
>





==============================================================================
TOPIC: Using MS SQL Express in my C# App
http://groups.google.com/group/microsoft.public.dotnet.languages.csharp/browse_thread/thread/19f9377dbede22ad?hl=en
==============================================================================

== 1 of 1 ==
Date: Sat, May 10 2008 7:55 am
From: "BlackWasp"


The compact edition is pretty good but check out the limitations first,
particularly if you are considering porting a database across from SQL
Server (Express) to CE.

--

BlackWasp
www.blackwasp.co.uk


"Todd Carnes" <toddcarnes@gmail.com> wrote in message
news:g02aql$2lr$1@aioe.org...
> Peter Bromberg [C# MVP] wrote:
>> As long as your application doesn't require the use of stored procedures,
>> you might want to consider shipping your app with SQL Server Compact 3.5
>> edition. It can be deployed by simply including the 7 required assemblies
>> and your database "SDF" file with your app; no special installation is
>> required. It also takes up *Way* less space.
>> --Peter
>
> I need to study the topic more before deciding which way to go, but the
> "compact" version sounds more like what I'm looking for so far.
>
> Thank you everyone for taking the time to share your suggestions, links,
> etc. with me. :)
>
> Todd






==============================================================================
TOPIC: On-Screen keyboard: how is it done?
http://groups.google.com/group/microsoft.public.dotnet.languages.csharp/browse_thread/thread/2c271c1b1558d911?hl=en
==============================================================================

== 1 of 4 ==
Date: Sat, May 10 2008 11:14 am
From: "Polaris"


Hi Experts:

I saw an PC without keyboard attached, it uses an on-screen keyboard
software program. When user clicks on a "key" (a button) on the program, the
program can find the currently active (focused) window application (for
example, notepad.exe) and input "typed" key into that active program; but
the keyboard program itself seems did not get activated while user click on
a button on it.

I could not figure out how it is accomplished? How does the keyboard program
avoid getting focus (active) even when user click on a "key" button of the
program? It must be able to do so in order to find the currently active
Windows program that user is working with (etc, a notepad.exe).

Thanks for your thoughts in advance.
Polaris







== 2 of 4 ==
Date: Sat, May 10 2008 11:40 am
From: Marcin Hoppe


Polaris pisze:
> Thanks for your thoughts in advance.

What I'd do if I were you and didn't want to buy an off-the-shelf
product (like itKeyboard from http://www.touch-soft.com/) would be to
download a trial version of an off-the-shelf product and use Spy++ to
look at messages that it sends and receives.

Best regards!
--
Marcin Hoppe
Email: marcin.hoppe@gmail.com
Blog: http://devlicio.us/blogs/marcin_hoppe




== 3 of 4 ==
Date: Sat, May 10 2008 11:45 am
From: "Scott Seligman"


"Polaris" <etpolaris@hotmail.com> wrote:
>
>I could not figure out how it is accomplished? How does the keyboard program
>avoid getting focus (active) even when user click on a "key" button of the
>program? It must be able to do so in order to find the currently active
>Windows program that user is working with (etc, a notepad.exe).

The window has the WS_EX_NOACTIVATE extended window style set.

--
--------- Scott Seligman <scott at <firstname> and michelle dot net> ---------
  The universe is driven by the complex interaction between three
  ingredients: matter, energy, and enlightened self-interest.
  -- G'Kar in Babylon 5:"Survivors"




== 4 of 4 ==
Date: Sat, May 10 2008 1:44 pm
From: "David Ching"


"Scott Seligman" <seligman@example.com> wrote in message
news:g04qfi$s1e$1@panix3.panix.com...
> The window has the WS_EX_NOACTIVATE extended window style set.
>

Very cool... I had not known about this style.  Before Win2K, the way to do
it was to intercept WM_MOUSEACTIVATE and return MA_NOACTIVATE (or
MA_NOACTIVATEANDEAT).

-- David







==============================================================================
TOPIC: After upgrade to 2.0, Error CS1595 System.TimeSpan is defined in
multiple places
http://groups.google.com/group/microsoft.public.dotnet.languages.csharp/browse_thread/thread/9dd6566f1396dd7c?hl=en
==============================================================================

== 1 of 2 ==
Date: Sat, May 10 2008 12:59 pm
From: brentbackup@gmail.com


I know I'm some years behind, but I just have the go-ahead to start
developing on .Net 2.0. While the development process goes ahead, I'm
to maintain the .Net 1.1 stuff on the same machine.

I downloaded and installed the 2.0 framework. As I understand it, 1.1
and 2.0 are supposed to play nice with each other. However, now when I
go about compiling a class using CSC.exe, I get this error (among
others):

---------------------
warning CS1595: 'System.TimeSpan' is defined in multiple places; using
definition from c:\WINDOWS\Microsoft.NET\Framework
\v1.1.4322\mscorlib.dll
---------------------

Despite "only" being a warning, the compilation doesn't seem to take,
such that the DLL is not produced.

I've done an exhaustive search on the machine for multiple
mscorlib.dll files. There are four, in these locations:

1) c:\I386\netfx.cab
2) c:\windows\servicepackfiles\i386
3) c:\windows\Microsoft.Net\framework\v.1.1.4322
4) c:\windows\Microsoft.Net\framework\v.2.0.50717

If necessary, I will uninstall 2.0. That will probably fix it. Short
of that, however, is there any other solution?

Thanks for any pointers.

--Brent




== 2 of 2 ==
Date: Sat, May 10 2008 1:53 pm
From: Marc Gravell


Are you intentionally referencing both 1.1 and 2.0? What csc command
are you using? Call me lazy, but I do like using tools like VS, which
will sort out this type of issue for us...

Marc





==============================================================================
TOPIC: Stop XmlDocument.Load() from using cached data?
http://groups.google.com/group/microsoft.public.dotnet.languages.csharp/browse_thread/thread/6f3892acd2eca71b?hl=en
==============================================================================

== 1 of 1 ==
Date: Sat, May 10 2008 1:04 pm
From: "Anthony Jones"


"Mahmoud Al-Qudsi" <mqudsi@gmail.com> wrote in message
news:6c6352fc-79bf-4139-ad55-b64db2a2ef7f@t54g2000hsg.googlegroups.com...
>
> > You will need to use HttpWebRequest if the default behaviour (or your
> > prevailing settings set via the requestCaching element in the
.config(s)) is
> > not want you need.
> >
> > I suggest you use a policy created wth Revalidate level.
>
> I take it this will this do the trick then?
>
> ....
> WebRequest.DefaultCachePolicy = new
> RequestCachePolicy(RequestCacheLevel.Revalidate);
> XmlDocument xmlDocument = new XmlDocument();
> xmlDocument.Load(myUri);

Assuming you don't have a conflicting setting in the application's config(s)
then yes that should do it.


--
Anthony Jones - MVP ASP/ASP.NET







==============================================================================
TOPIC: Displaying high-res images in .NET?
http://groups.google.com/group/microsoft.public.dotnet.languages.csharp/browse_thread/thread/f4ebe66b3f4ed2b7?hl=en
==============================================================================

== 1 of 1 ==
Date: Sat, May 10 2008 1:39 pm
From: Barry Kelly


Ben Voigt [C++ MVP] wrote:

> Barry Kelly wrote:
> > Ben Voigt [C++ MVP] wrote:
> > > [...]

> > Depending on the image file format, for any given cropped area, each
> > subsequent scan line of pixels / pixel groups will likely be very
> > distant in the file, many strides away. IMO a view that builds up a
> > screen-viewable picture, whether zoomed out (and thus an aggregate of
> > data) or zoomed in, is best off processing the file in a forward-only
> > fashion to pick up the data it needs. To get efficient scrolling, a
> > combination of caching and prediction would probably help.
>
> MapViewOfFile should gracefully degrade to this, but use memory when
> possible.

MapViewOfFile will only directly help if the image is a raw bitmap and
you're displaying it with a image pixel to screen pixel ratio <= 1, and
even then it'll be limited. Since you'll need to copy each slice of
pixels into a single bitmap for actual on-screen display, you don't save
as much as you could when avoiding a copy by piggybacking the VM/FS
caching subsystem, IMO.

Zoomed out, you need to aggregate data from multiple pixels for each
on-screen pixel, possibly many, many pixels. Since those aggregates
would be expensive to create, you'd want to both cache them and
predictively (or exhaustively, offline) calculate them. Ideally the
image format itself would provide for this, as they'd be very expensive
to create.

> > To get it really efficient, IMO you'd need to get the whole thing into
> > memory either on multiple machines or in a single 64-bit address
> > space. Having an image server that has tiles at different zoom
> > levels, and perhaps using interpolation, something along the lines of
> > Google Maps / Earth, seems a pretty inevitable design for maximum
> > flexibility.
> >
> > Some file formats might help; quadtree or z-order may reduce
> > stride-induced random access.
>
> Thanks for sharing your wisdom... I wish I knew more about some of those but
> they seem kind of specialized, I haven't encountered a need for them.

Z-order is a space-filling curve, a kind of fractal that is recursively
made up of Z-shaped strokes. It's described on Wikipedia reasonably
well, which is where I went to refresh my memory of the traversal:

http://en.wikipedia.org/wiki/Z-order_(curve)

Quadtrees are involved in a number of image algorithms, as a search on
Google will show, and Z-order is a depth-first traversal of a quadtree.

For example, the aforementioned aggregate data can be inferred from a
quadtree by successively ignoring leaves after a given depth. However,
that requires you to have constructed a quadtree already, which
effectively has MIPs built-in to the node colours.

Very brief intro to quadtrees:

http://www.cs.ubc.ca/~pcarbo/cs251/welcome.html

-- Barry

--
http://barrkel.blogspot.com/





==============================================================================
TOPIC: Console.ForegroundColor per thread getting jumbled.
http://groups.google.com/group/microsoft.public.dotnet.languages.csharp/browse_thread/thread/8e56b5d7b87c520c?hl=en
==============================================================================

== 1 of 2 ==
Date: Sat, May 10 2008 2:22 pm
From: Aju


lock (o)
           {
               Console.ForegroundColor =
(ConsoleColor)Enum.Parse(typeof(ConsoleColor),
Attributes["ConsoleColor"]);
               Console.Write(message);
               Console.ResetColor();
           }

I hoped each thread would get it's own color based on an external
parameter that's set at load time. However, ocassionlly outputs means
to be in green are coming out in red and so on.

Any ideas?




== 2 of 2 ==
Date: Sat, May 10 2008 2:34 pm
From: Marc Gravell


Well, I was going to say "add some locking"... so: what is "o"
here...? not everything is suitable for locking... and it must be the
same reference over all threads - the following would suffice:

public static class SharedLock {
 public static readonly object Lock = new object();
}

then lock(SharedLock.Lock) {...}

Marc






==============================================================================
TOPIC: Can't Post Online
http://groups.google.com/group/microsoft.public.dotnet.languages.csharp/browse_thread/thread/38867ee7dafd61fc?hl=en
==============================================================================

== 1 of 1 ==
Date: Sat, May 10 2008 2:34 pm
From: "jp2msft"


Microsoft updated their website interface, and now I am no longer able to
post questions. I log in and get to the screen where I select New >
Question. The page refreshes, but the question window never appears. How do
I get the question window? My pop-up blockers (Google and IE7) have both
been disabled, and I am doing this from home and work (work has a proxy,
home does not).



No comments: