Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1
  • 2

TOPIC:

Issues with creating a new WPF X# program 10 May 2022 17:51 #22399

  • ic2


  • Posts: 1351
  • I've got 2 issues with creating a new WPF X# program.

    First is probably one of the many dreadful VS issues, maybe someone knows how to prevent that. When I right click Add, New project, WPF Application (X#), the suggested project name is WpfApplication1. I change that, click Create, the namespace is now the name I've chosen but the class name looks as follows:

    PUBLIC PARTIAL CLASS WPFWindow1 INHERIT Window

    How can I prevent the class to be called WPFWindow1?

    Now you would probably say, just rename all occurrences of WPFWindow1 with YourName.

    I did. Then the program doesn't start anymore (without a visible error). In debug mode however I get:

    System.IO.IOException: 'Cannot locate resource 'yourname.xaml'.'

    So I want to either prevent having the wrong class name to start with or if that is not possible, rename my class and prevent or solve this stupid VS error. How can I do that?

    Another issue is that when I select, in WPF XAML, Click="MyMethodName" and press F12 (goto definition) this does not work in X# (it does in C#). You get an errorbox Cannot navigate to definition.

    In C# it would create the event MyMethodName with all parameters. It will almost sure be totally mislocated in the code, which is a logical result of the deficient VS design, but at least I get my method to start with.

    Also when the method is created F12/Goto definition on the Click event in XAML won't work in X#.

    Is that something which can be fixed?

    Dick

    Please Log in or Create an account to join the conversation.

    Last edit: by ic2.

    Issues with creating a new WPF X# program 10 May 2022 18:05 #22400

    • Chris
    • Chris's Avatar


  • Posts: 3256
  • Hi Dick,

    From what I see, c# using a different naming scheme for the window that gets autocreated, and names it "MainWindow", which I guess is much more appropriate than the "WPFWindow1" that X# generates. I will add log this is as a request for Robert to change this, as this would already make changing the name less necessary. Still, it is possible to change the name and do it without breaking everything in the project, but I will let the WPF gurus to explain how to do it.

    About picking a totally custom name for the window in advance, when creating the new project, that would involve specifying this name in some extra dialog or something, and I'm not aware if VS supports something like that (XIDE does :)), so I am not sure if it;s possible to do it somehow.

    The problem with Goto Definition in the XAML is I guess soemthing that's not implemented yet in X#, will log this as well, thanks.

    .
    XSharp Development Team
    chris(at)xsharp.eu

    Please Log in or Create an account to join the conversation.

    Last edit: by Chris.

    Issues with creating a new WPF X# program 10 May 2022 18:20 #22401

    • Chris
    • Chris's Avatar


  • Posts: 3256
  • Hi Dick,

    Actually, renaming a WPF window is very easy! All you need is to go to the solution explorer and rename the main tree item for the window (WPFWindow1.xaml) to the new names, and then everything else happens automatically and the project builds with no errors. I just tried it, it does work also with X#.

    Edit: Oops, sorry...It builds, but it does not run (as you said :)). Will log a report...
    Edit2: Oops again, I tried also with c# and it also has the same problem!!! OK, I will not make a comment about VS or WPF (or open a report), I will let the guys who know explain how to change the name properly...
    .
    XSharp Development Team
    chris(at)xsharp.eu

    Please Log in or Create an account to join the conversation.

    Last edit: by Chris.

    Issues with creating a new WPF X# program 10 May 2022 21:31 #22402

    • ic2


  • Posts: 1351
  • Hello Chris,

    Chris wrote: Hi Dick,

    About picking a totally custom name for the window in advance, when creating the new project, that would involve specifying this name in some extra dialog or something, and I'm not aware if VS supports something like that (XIDE does :)), so I am not sure if it;s possible to do it somehow..


    I don't think it's possible in VS but hey, Microsoft doesn't employ developers from your caliber so they won't even come to the idea that this is something that should have been implemented :unsure:

    Dick

    Please Log in or Create an account to join the conversation.

    Issues with creating a new WPF X# program 10 May 2022 23:08 #22403

    • robert
    • robert's Avatar


  • Posts: 2834
  • Dick,
    The App.Xaml fole contains the name of the first windows that has to be shown:

    <
    Application x:Class="$safeprojectname$.$safeitemname$"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        StartupUri="WPFWindow1.xaml">
        <Application.Resources>
             
        </Application.Resources>
    </Application>
    
    You need to change the name there to match your new mainwindow name.


    Robert
    XSharp Development Team
    The Netherlands

    Please Log in or Create an account to join the conversation.

    Issues with creating a new WPF X# program 10 May 2022 23:31 #22404

    • ic2


  • Posts: 1351
  • I solved it as follows. In an external program UltraFileSearch I searched for all occurrences of WPFWindow1 and replaced it in a texteditor by my class name. E.g.:

    <Window x:Class= (namespace.class) in the .xaml window
    StartupUri=... in the app.xaml
    plus in a couple of obscure programs like D:\XSharpProjects\MyProgram\obj\DebugApp.g.i.prg and App.g.prg.

    One program is still called WPFWindow1.g.i.prg but that seems no real problem.

    Did I tell you I hate Visual Studio?

    I found some remarks leading me into this direction on Stackoverflow NINE years ago.
    None of those low brain VS "engineers" has cared to fix a serious bug during a simple action to rename a class.

    I keep wondering why Microsoft hasn't been declared bankrupt many years ago.

    Dick

    Please Log in or Create an account to join the conversation.

    Issues with creating a new WPF X# program 10 May 2022 23:35 #22405

    • Chris
    • Chris's Avatar


  • Posts: 3256
  • Well, they are too big and also too many people (like us) depend on them unfortunately, so...
    XSharp Development Team
    chris(at)xsharp.eu

    Please Log in or Create an account to join the conversation.

    Issues with creating a new WPF X# program 11 May 2022 09:01 #22406

    • robert
    • robert's Avatar


  • Posts: 2834
  • Dick,

    ic2 wrote: <Window x:Class= (namespace.class) in the .xaml window
    StartupUri=... in the app.xaml
    plus in a couple of obscure programs like D:\XSharpProjects\MyProgram\obj\DebugApp.g.i.prg and App.g.prg.
    One program is still called WPFWindow1.g.i.prg but that seems no real problem.


    Those .g.prg and .g.i.prg inside the obj folder are generated by the build system from the xaml files. They can be safely deleted. I think the "G" is for "Generated" and the "I" is for "Intellisense".

    Robert
    XSharp Development Team
    The Netherlands

    Please Log in or Create an account to join the conversation.

    Issues with creating a new WPF X# program 11 May 2022 18:00 #22411

    • ic2


  • Posts: 1351
  • Thank you Robert, I added this to my notes in the chapter "How to solve problems which wouldn't exist if Microsoft were an actually capable software company" :angry: .

    DIck

    Please Log in or Create an account to join the conversation.

    Issues with creating a new WPF X# program 11 May 2022 19:07 #22412

    • Terry


  • Posts: 281
  • Hi Dick

    There are a number of places in a program where you have to tackle two actions in concert and this is one of them.

    Essentially what you see and build using SloutionExplorer is a directory structure. What you code in your program is a set of namespaces. So you have Directory linkages and Code linkages which are independent but must marry up or you'll end up in a mess.

    This is easier to show diagrammatically so I have attached a JPEG which I hope helps.

    Terry

    Please Log in or Create an account to join the conversation.

    Issues with creating a new WPF X# program 12 May 2022 11:07 #22417

    • ic2


  • Posts: 1351
  • Hello Terry,

    I understand that.

    If Microsoft developers also had some basic understanding of these concepts, their users wouldn't need to waste time with trying to get things working after such a simple action as renaming a default class name into a meaningful name.

    Dick

    Please Log in or Create an account to join the conversation.

    Issues with creating a new WPF X# program 12 May 2022 11:20 #22418

    • Chris
    • Chris's Avatar


  • Posts: 3256
  • Hi Dick,

    I'm sure there are tons of extremely good programmers in MS. I suspect their structure is their problem, where they have managers for even very trivial stuff, product managers, managers managing managers, managers for managing management managing projects and so on..

    I'm not sure how easy is for their smartest people to have things properly done in such an environment...

    .
    XSharp Development Team
    chris(at)xsharp.eu

    Please Log in or Create an account to join the conversation.

    Issues with creating a new WPF X# program 12 May 2022 12:25 #22421

    • Terry


  • Posts: 281
  • I'm sure there's truth in all comments here, and as Chris says the spiders web of managers cannot help.

    But if I take your statement literally, Dick, of simply renaming a class causing a problem, then it is something I have done many times without any problem. I know I am talking C# but it should apply across the board for all supported languages.

    Terry

    Please Log in or Create an account to join the conversation.

    Issues with creating a new WPF X# program 12 May 2022 14:17 #22423

    • ic2


  • Posts: 1351
  • Hello Terry,

    Terry wrote: But if I take your statement literally, Dick, of simply renaming a class causing a problem, then it is something I have done many times without any problem. I know I am talking C# but it should apply across the board for all supported languages.


    Then I would love to hear what you are doing differently than I did (or Chris did):

    1 Add, New project
    2 I change Project name WpfApplication1 to IC2WebExchange and, somewhere at the other end of my screen, there's a button Create
    3 Now my XAML code says <Window x:Class="IC2WebExchange.WPFWindow1" so I rename WPFWindow1.xaml to WebExchange.xaml in the Solution Explorer.
    4 This time I get a new VS surprise: Error HRESULT E_FAIL has been returned from a call to a COM component. But after 2 retries it works. Sometimes something works in VS, but not often directly.
    5 Now both the xaml and the code behind .prg have been renamed. The program crashes as described above, which you only see in the debugger.
    6 With an external program, I search for occurrences of WPFWindow1 and find these in app.xaml and the renamed xaml program + code behind.

    Dick

    Please Log in or Create an account to join the conversation.

    Issues with creating a new WPF X# program 12 May 2022 14:18 #22424

    • ic2


  • Posts: 1351
  • Hello Chris,

    Chris wrote: Hi Dick,
    managers for managing management managing projects and so on..
    .


    I am afraid you are right. So supposing that Microsoft does have good programmers, the question is then shifted towards "why don't they have good managers?"

    Dick

    Please Log in or Create an account to join the conversation.

    Issues with creating a new WPF X# program 12 May 2022 14:39 #22425

    • ic2


  • Posts: 1351
  • I've got another issue I fail to understand.

    Within an X# solution containing multiple libs & exe's, I created that new WPF program. I want to rewrite an existing program to exchange MySQL webdata to get rid of the WCF code in that program. Currently the only difference is that I started this as an X# WPF program. I included the same X# DLL's (Core/Rdd/RT/VoRDDClasses/VoSystemClasses. I added an existing program (so Include statements are the same as well).

    When I compile I get:

    Error XS0246
    The type or namespace name 'DbServer could not be found (are you missing a using directive or an assembly reference?)


    Why? What am I missing?

    Dick

    Please Log in or Create an account to join the conversation.

    Last edit: by ic2.

    Issues with creating a new WPF X# program 12 May 2022 15:16 #22426

    • Terry


  • Posts: 281
  • Hi Dick

    Just to acknowledge your last. It ceratinly merits looking into and I'll do so over the next few days.

    There is some deeper problem/misunderstanding here - I've never had HRESULT errors, nor am I using PRG's.

    On the face of it, it looks like problems looking in to legacy code. A problem I'm not likely to have with what I'm doing at the moment. I'm using VS 2022.

    But none of that changes the basic principles. Need to give it more thought.

    Terry

    Please Log in or Create an account to join the conversation.

    Issues with creating a new WPF X# program 12 May 2022 15:37 #22427

    • Chris
    • Chris's Avatar


  • Posts: 3256
  • Hi Dick,

    Not sure what those items in your error description mean, like those "X# Website" etc. Maybe a screenshot would help.

    The error itself means that either you have not added references in your app/library to the required dlls (VORDDClasses.dll in this particular case), or you are trying to use the class "VO.DBServer" with its short name "DBServer", without a "USING VO" statement, or without having enabled the "Enable Implicit Namespace lookup" project option, which tells the compiler to do this automatically.

    .
    XSharp Development Team
    chris(at)xsharp.eu

    Please Log in or Create an account to join the conversation.

    Issues with creating a new WPF X# program 12 May 2022 19:11 #22435

    • ic2


  • Posts: 1351
  • Hello Chris,

    Chris wrote: or without having enabled the "Enable Implicit Namespace lookup" project option, which tells the compiler to do this automatically.
    .


    Of course, that's it again. Thanks!

    As the new project was a part of an existing solution I simply didn't realize to go the project's Language settings, as I should have :blush:


    Chris wrote: Not sure what those items in your error description mean, like those "X# Website" etc. Maybe a screenshot would help.
    .


    Oh, that was because I copied the error message from the X# web help. I will now edit the leading lines away....

    Dick

    Please Log in or Create an account to join the conversation.

    Last edit: by ic2.

    Issues with creating a new WPF X# program 16 May 2022 12:42 #22476

    • ic2


  • Posts: 1351
  • Hello Chris,

    I have 1 additional question here.

    I did include VORDDClasses. Why doesn't it work then (as the only part of the program) without Implicit namespace lookup?

    And why should I add, without implicit lookup, VO.DBServer or Using VO? This doesn't work either (Error XS0246 The type or namespace name 'VO' could not be found ) .

    What does the implicit lookup lookup exactly what I can't achieve in he program?

    Dick

    Please Log in or Create an account to join the conversation.

    • Page:
    • 1
    • 2