Click here to Skip to main content
15,889,462 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have this simple compiler which where I can compile C# Console applications..

And when I try compile this code

C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WindowsInput;
using System.Windows.Forms;

namespace ScreenshotConsole
{
    class Program
    {


        static void Main(string[] args)
        {
            screenshot();
            Console.WriteLine("Printescreened");
            Console.ReadLine();
        }


        static void screenshot()
        {
            SendKeys.SendWait("{PRTSC}");
        }

    }
}



It throws me this error

C#
The type or namespace name 'WindowsInput' could not be found (are you missing a using directive or an assembly reference?)


I've already added the
C#
parameters.ReferencedAssemblies.Add("System.dll");


And as far as I know it should be the the only dll needed.



Source code for the compiler.

C#
using Microsoft.CSharp;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Forms;



namespace SimpleBuilder
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// store code
    /// select what features
    /// print out textfile with all the code from the features
    /// compile that textfileContent to a exe
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }
        
        private void fakeMessageOne()
        {
            if(fakeMessageCheckbox.IsChecked == true)
            {
                fakeMessage1 fkmsg = new fakeMessage1();
                fkmsg.fakeMessage();
            }
        }

        private void button_Click(object sender, RoutedEventArgs e)
        {
            
            

            CSharpCodeProvider csc = new CSharpCodeProvider(new Dictionary<string, string>() { { "CompilerVersion", frameworkTextbox.Text } });
            CompilerParameters parameters = new CompilerParameters(new[] { "mscorlib.dll", "System.Core.dll" }, outputTextbox.Text, true);
            parameters.GenerateExecutable = true;
            parameters.ReferencedAssemblies.Add("Microsoft.CSharp.dll");
            parameters.ReferencedAssemblies.Add("System.dll");
            parameters.ReferencedAssemblies.Add("System.Windows.Forms.dll");
            parameters.ReferencedAssemblies.Add("System.Management.dll");

            parameters.ReferencedAssemblies.Add("WPF\\PresentationFramework.dll");
            parameters.ReferencedAssemblies.Add("System.Xaml.dll");
            parameters.ReferencedAssemblies.Add("WPF\\WindowsBase.dll");
            parameters.ReferencedAssemblies.Add("WPF\\PresentationCore.dll");

            CompilerResults result = csc.CompileAssemblyFromSource(parameters, sourceTextbox.Text);
            if (result.Errors.HasErrors)
            {
                result.Errors.Cast<CompilerError>().ToList().ForEach(error => errorTextbox.Text += error.ErrorText + "\r\n");
            }
            else
            {
                errorTextbox.Text = "--- Build Succeeded! ---";
            }

        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            Builder bldr = new Builder();
            bldr.Visible = true;
        }
    }
}


What I have tried:

I've tried reading and asking on SO but no help over there.
Posted
Updated 28-Sep-16 17:27pm

Your code indicates that the using statement is
C#
using WindowsInput
.

At first glance, this is not a .net library namespace so the only person who can tell you what namespace to use is whoever wrote that library.

A quick google search may lead me to believe you made a mistake and mean to use System.Windows.Input?

Google[^]

System.Windows.Input Namespace[^]

If you didn't mean System.Windows.Input then I am afraid you need to talk with other people working on your project or the person who wrote your library. Remember, we don't have access to your hard rive, we don't have access to your code nor do we read minds or know anything about your project.

This issue is pretty clear however, you either have a type in your namespace or are using the wrong namespace of a library your team/members of your project have decided to use.
 
Share this answer
 
Comments
Goober S. Johnsson 28-Sep-16 23:44pm    
Omg.. I just had to remove that namespace..
Thanks! :D
You have a "using WindowsInput;" line near the top of your code. There's no such namespace in the .NET Framework.

What are you really trying to do with this code and what classes are you trying to use?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900