Application.Run(new Form1) method and using list missing - winforms

I'm using VB 2010 express to create a simple forms application, no problem when I run it but why didn't I have to type the Application.Run() method to get it to work as I did in the past and why is this missing?
I've checked the show all files in solution explorer.
Also my form code doesn't list the usual using namespaces at the top of the code either!

Related

Design time errors when working in .NET 3.5 and adding charts after reopening the designer

Unfortunalty I need to use .NET 3.5 and use charts in the designer. Everything works quite well. I have added a package Microsoft Chart Controls that are not there by default with .NET 3.5 and added the dlls to the tools bar and to the reference.
I able to have the chart displayed in the designer and work with its data in the class. Problems start if I close the designer window and then open it again - I get a bunch of design time errors!
The strangest thing is that the code compiles and the chart works well in the application. Also the code behind in the auto generated design.cs stays untouched but i get millions of errors such as:
Has anyone come across a similar situation? Don't know how to go around it. I am using Visual Studio 2017. Thanks!
I think you have to add reference of this dll
System.Windows.Forms.DataVisualization.Charting.ChartArea
If this error will showing continuously then
Please add a new Winform and add a chart control.
then write your code in new created form . it will work.

Best Starting Point for WPF Revit Add in

I am wanting to rewrite one of my Revit Add ins so that it utilizes WPF with MVVM because I like the look and functionality of WPF better than Windows Forms.
I have used the Revit Template Wizzard from Jeremy Tammik for the Form based add in, but adding a WPF user control seems not to work (a run time error that the xaml resource cannot be found).
I found a WPF MVVM revit add in example (AddMaterials, here is the github link, which will add materials from an Excel spreadsheet) but it does not follow what I am expecting to see at the top level.
Revit Add ins have an app.cs file which tells Revit how to register and access the DLL (ribbon panel buttons etc).
A windows WPF app will have app.xaml as the top level entry point.
The Add Materials project has neither which tells me that it must be
a class library, however the views are not using UserControls
rather they are Windows which I prefer. However Visual Studio does not
let you add a Window for a Class Library type project.
The third issue is easily solved by simply copying windows from a WPF application project into a class library project. But I don't really understand how the class library will instantiate in Revit without following the app.cs code from the template. Is anyone else creating add-ins this way, and if so can you let me in on any tricks or discussions that will help? Has anyone created a WPF Revit addin template for Visual Studio?
When I add a WPF window and try to instantiate it I get an error that it cannot find the xaml resource (System.IO.IOException: Cannot locate resource 'xxxx.xaml'). I have tried to fix this according to advice found when googling for this error, but to no avail. I am thinking it comes from being in a form based project, and that I may have to just start with a new project without the form stuff.
I have now verified that indeed you can start with the Revit AddIn Wizzard and use WPF . . . I started from scratch and copied in a window created in another project and got it to run (after adding the various references, namespaces, etc). So my problem seems to just be with the original project which already had a bunch of form stuff added.
Yes, I'm using WPF to create Revit Addins. It works well. You can easily create your own WPF template from the SDK samples:
Start with one of the Autodesk-provided SDK samples. I used the "DockableDialogs" sample. I know this one works, your mileage may vary with the others. If you're looking for windows rather than docked panes in the UI, another sample (perhaps the AddMaterials sample) is probably simpler.
I used Visual Studio to turn the sample into a template. File - Export Template -> select "DockableDialogs" or other WPF sample project.
Create a new project based on the template you just created. This was the easiest method I could find to get the WPF internal bits wired up correctly.
I'm not specifically familiar with the AddMaterials project, but to clarify your bullet points.
Revit Addins - It's not the file name (app.cs) but rather they must extend IExternalApplication or IExternalCommand. If you are creating a xaml interface (rather than just running a command from a ribbon button) you'll use 'IExternalApplication' as your entry point. Look for something like this in the sample:
public class ThisApplication : IExternalApplication ...
I don't used a top level app.xaml, but instead have page.xaml pages which are called by the Revit app. In my case these are Pages rather than Windows, which extend the IDockablePaneProvider class. These must be registered with the application which can then can be show, hide, etc your Panes. I imagine this is simpler with Windows, but haven't done it myself. For the dockable panes, your xaml.cs should start out something like:
public partial class MainPage : Page, Autodesk.Revit.UI.IDockablePaneProvider ...
Yes, the project is a class library in the sense that it is a collection of classes, at least one of which extends IExternalApplication or IExternalCommand. Remember that you're not creating a standalone application, but adding functionality to an existing Windows application (Revit). Revit will instantiate the ThisApplication class and then call its .OnStartup() method when the Revit application starts. This shouldn't stop you from adding .xaml or .cs files to the project, though. I can do it using VS Community 2015 using Ctrl-Shift-A.
Hopefully this gets you started - I've been able to implement a WPF UI in Revit without any prior WPF experience, and I'm not even a real programmer, so it's definitely possible. Good Luck!
addendum
If you want to add WPF elements to an existing revit addin, you can follow the instructions here: How can I connect xaml and xaml.cs files
Ultimately I found it easier to migrate my addin code into a template made from a working sample, you may want to try this approach as well.

WPF User Control Library - Does not exsist in the namespace

I'm new to WPF.
I'm trying to create a WPF application with WPF User Control Library.
But when I try to build or run the project I'm getting the following errors.
I have added the reference to the starting project.
The name "HoverButton" does not exist in the namespace "clr-namespace:HomeSchool_KinectControls;assembly=HomeSchool_KinectControls;"
When I remove the Canves and other elements inside it and build, It successfully built. But when I try to use the HoverButton the error is appearing again and the project is not getting build.
I have seen it's kinda bug in the VS and I tried following:
Restarting VS
Change the Targeting Build Platform
And it doesn't work.
Please help me to find a solution.
From your code it is seen that you're trying to access the Hoverbutton from a certain library.
It is not possible to access a library without adding a reference to it.Right Click on References under the solution explorer and select Add reference. Now browse to the required library or select it if it is in GAC. It will solve your issue.

Error when creating crystal report in WPF application

I have a WPF application, PRISM + Unity, and have created a ReportingModule.
As of yet this is proof of concept.
My module simply has a single report that I want users to be able to select and view. I have the report.rpt file created and can preview the report, seeing data, however when I try and run my application I get an error
"The type or namespace name 'ReportingModule' could not be found (are you missing a using directive or an assembly reference?)". If I comment out the code behind the .rpt file I can run my application. Why would simply creating a crystal report file break my application????
Confused.
Add a using directive to your code or add a reference to your project to be able to use Crystal Reports. And if you add your sample code you may even receive more concrete help.

SharePoint embed of Silverlight app breaking ControlTemplates

Strange problem here, I have a page with 4 ControlTemplates declared in the page resources. In the code for the page, I declare a reference to each of these ControlTemplates so that I can use them in binding. This works fine Out-Of-Browser, and In-Browser, except when it is running in the Silverlight Web Part in SharePoint. In SharePoint, the buttons that I want templated are shown as just normal buttons with the class as the text instead of the special layout and content I define in the template. Any idea why it would work everywhere but in SharePoint?
While I am not sure what caused the null reference only while being ran in SharePoint, I refactored my code to make the ItemsControl.ItemsSource reference a property instead of a single assignment of a List<> to it. Now it is working just like it should.
Helpful in figuring this out was the ability to attach Visual Studio to the Internet Explorer (didn't work so well for Chrome) process that was running the Silverlight Web Part. This is found in Visual Studio by going to the Tools menu > Attach to Process. Which IE process it is will be obvious as it will have Silverlight in the Type column.

Resources