C
C#16mo ago
Laz

✅ C# CS0246

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Autodesk.Revit.ApplicationServices;
using System.Windows.Forms;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using Autodesk.Revit.Attributes;

namespace WallFinishPlugin
{
[Transaction(TransactionMode.Manual)]
public class Main : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
var uiapp = commandData.Application;
var uidoc = uiapp.ActiveUIDocument;
var app = uiapp.Application;
var doc = uidoc.Document;

var collector = new FilteredElementCollector(doc)
.OfCategory(BuiltInCategory.OST_Walls);

var simpleForm = new SimpleForm();
simpleForm.ShowDialog();


return Result.Succeeded;

}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Autodesk.Revit.ApplicationServices;
using System.Windows.Forms;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using Autodesk.Revit.Attributes;

namespace WallFinishPlugin
{
[Transaction(TransactionMode.Manual)]
public class Main : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
var uiapp = commandData.Application;
var uidoc = uiapp.ActiveUIDocument;
var app = uiapp.Application;
var doc = uidoc.Document;

var collector = new FilteredElementCollector(doc)
.OfCategory(BuiltInCategory.OST_Walls);

var simpleForm = new SimpleForm();
simpleForm.ShowDialog();


return Result.Succeeded;

}
}
}
Following https://www.youtube.com/watch?v=YV16JmCGNZA&list=PLABAnZRsrrL4xoeLvEmqtayeRC5b5GuwU&index=5&ab_channel=MariyanDeveloper At 13;06 The SimpleForm() has an error of CS0246, I have added -> using System.Windows.Forms; but still does not work Can somebody help? (edited)
Mariyan Developer
YouTube
Revit API Course for beginners | Lesson 3 | Element Selection
In this lecture you will learn about selection of Revit element via its API. We will discover what is the main class for doing it and how to use it. I hope you enjoy the session and learn something new! Feel free to comment any feedback/questions below, or follow my channel if you enjoyed this. If you want to get online classes text me on insta...
24 Replies
Pobiega
Pobiega16mo ago
CS0246 is
the type or namespace name 'type/namespace' could not be found (are you missing a using directive or an assembly reference?)
could you perhaps say what type/namespace the error is giving you? and show your .csproj file
Laz
LazOP16mo ago
Sorry im extremely new to C# and codinig in general can you guide me where .csproj is? i think i found it
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{834B8604-91D3-40DD-B8C0-341F57EC2B62}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Mariyan_Developer</RootNamespace>
<AssemblyName>Mariyan Developer</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{834B8604-91D3-40DD-B8C0-341F57EC2B62}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Mariyan_Developer</RootNamespace>
<AssemblyName>Mariyan Developer</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>

</PropertyGroup>
<ItemGroup>
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="RevitAPI">
<HintPath>..\..\..\..\..\..\..\..\Program Files\Autodesk\Revit 2022\RevitAPI.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="RevitAPIUI">
<HintPath>..\..\..\..\..\..\..\..\Program Files\Autodesk\Revit 2022\RevitAPIUI.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xaml" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<Compile Include="Class1.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SimpleForm.cs" />
<Compile Include="SimpleForm.xaml.cs">
<DependentUpon>SimpleForm.xaml</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<Page Include="SimpleForm.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
</PropertyGroup>
<ItemGroup>
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="RevitAPI">
<HintPath>..\..\..\..\..\..\..\..\Program Files\Autodesk\Revit 2022\RevitAPI.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="RevitAPIUI">
<HintPath>..\..\..\..\..\..\..\..\Program Files\Autodesk\Revit 2022\RevitAPIUI.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xaml" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<Compile Include="Class1.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SimpleForm.cs" />
<Compile Include="SimpleForm.xaml.cs">
<DependentUpon>SimpleForm.xaml</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<Page Include="SimpleForm.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
Laz
LazOP16mo ago
No description
Pobiega
Pobiega16mo ago
This is a .NET Framework project. .NET Framework is really old and outdated, and should not be used for new projects or learning without very good reason. The last version of Framework was made in 2016
Laz
LazOP16mo ago
Its supposed to be used in conjunction with ReVit to make API Plugins Its what im given to use
Pobiega
Pobiega16mo ago
Ugh Okay, I'd strongly urge against learning C# via this method but you do you This line indicates that you don't have a type called SimpleForm imported
Laz
LazOP16mo ago
I have no idea what im doing too, i was originally from C++ then my school pushed C# on to my entire cohort...
Pobiega
Pobiega16mo ago
C# is a great language, but using a 6 almost 7 year old version of it is a bit silly
Laz
LazOP16mo ago
No description
No description
Laz
LazOP16mo ago
No description
Pobiega
Pobiega16mo ago
SimpleForm isn't anything I've ever heard of before so its either something related to ReVit, or you are supposed to make it yourself
Laz
LazOP16mo ago
Usercontrol was replaced with SimpleForm
Pobiega
Pobiega16mo ago
<Compile Include="SimpleForm.cs" />
Laz
LazOP16mo ago
Then another error appeared I followed the video wrongly
Pobiega
Pobiega16mo ago
<Compile Include="SimpleForm.xaml.cs">
wait what If this is winforms, you can't use xaml Yeah you've made a pretty big mistake somewhere I think your SimpleForm was created as a WPF window, not a winforms form
Laz
LazOP16mo ago
Yes WPF They said to use WPF...
Pobiega
Pobiega16mo ago
.. okay
Laz
LazOP16mo ago
No description
Pobiega
Pobiega16mo ago
Then why are you talking about using System.Windows.Forms; thats the winforms namespace, which is a different GUI toolkit
Laz
LazOP16mo ago
I was looking in the comments section and a poster said to include it, and i did what they said...
Pobiega
Pobiega16mo ago
¯\_(ツ)_/¯ You do you. You're following an old tutorial, for an old project, based on an outdated framework.
Laz
LazOP16mo ago
Nvm... I found my error... How do i close this
Pobiega
Pobiega16mo ago
$close
MODiX
MODiX16mo ago
Use the /close command to mark a forum thread as answered

Did you find this page helpful?