Questions tagged [csharpcodeprovider]

.NET class that provides access to the C# compiler for compiling code.

CSharpCodeProvider can be used by applications to compile C# source code from in-memory strings or from files on disk, producing in-memory compiled assemblies or DLL files on disk.

153 questions
1
vote
3 answers

Method not found: when send request web api controler

When I try to invoke api method I'm getting exception like Method not found: 'Void System.Web.Http.Filters.HttpActionExecutedContext.set_Response(System.Net.Http.HttpResponseMessage)'. ApiController:- [System.Web.Http.HttpGet] public…
1
vote
0 answers

VS 2017, Direct CSharpCodeProvider to use C#7

When implementing C#7 feature ($ - string interpolation) in my xcript, and calling CSharpCodeProvider.CompileAssemblyFromSource(), I receive the following error: E:\src\*****\****\bin\Debug> "C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe"…
1
vote
1 answer

how to give xml file source in app.config and write/read those xml files form winform?

DataSet ds = CreateDynamicDataSet(); ds.WriteXml(@"E:\AppScienti\AppScienti-POSLite\POSLite-Dev\XML\POSLite.xml"); private DataSet CreateDynamicDataSet() { DataSet ds = new DataSet("DS"); //ds.Namespace = "StdNamespace"; …
1
vote
0 answers

How to get english Warnings and Errors from CS-Script

I use CS-Script to compile code at runtime. I do this like follow and read the generated Errors and Warnings after out of the ComipilingHistory: var eval = CSScript.Evaluator; var assembly = eval.CompileCode(code); if…
BennoDual
  • 5,865
  • 15
  • 67
  • 153
1
vote
1 answer

Runtime C# Compile All Files in a Folder from Code

I am successfully doing run-time compilation using the code below. Except that when the number of input *.cs files is large I get the following error. System.SystemException: Error running mono.exe: The filename or extension is too long. I believe…
Abdalla
  • 2,071
  • 2
  • 16
  • 27
1
vote
1 answer

CSharpCodeProvider how to reference current assembly

I'm trying to dynamically compile code using CSharpCodeProvider. In the referenced assemblies, I'm adding a reference parameter for typeof(Program).Assembly.CodeBase), as was suggested here, but it doesn't work. I still get an error saying error…
user756366
  • 467
  • 6
  • 24
1
vote
0 answers

CSharpCodeProvider freezes my mvc application

I need to create some Dll files at runtime. The Dll's are getting generated, but it seems that the mvc application freezes AFTER this code is executed. In the output window, I can see that all my Dll's are getting unloaded and after that they all…
Herole
  • 11
  • 2
1
vote
2 answers

Generate DbContext using CSharpCodeProvider

using the below code i generate OnlineShopContext at runtime string code = @" using System.Data.Entity; using GenerateContext.Models; using System.Data.Entity.Core.EntityClient; using…
1
vote
1 answer

CreateValidIdentifier() fails to check name

I am using CreateProvider() to check if a string is good variable name. var codeDomProvider = CodeDomProvider.CreateProvider("C#"); var goodName = codeDomProvider.CreateValidIdentifier("ab.cd"); surprisingly, it gives me back 'ab.cd'. …
CaTx
  • 1,421
  • 4
  • 21
  • 42
1
vote
1 answer

Getting the file path of the .cs file where a type was declared

I'm working on a procedural asset generation system and I want it to be able to detect if the source file of a particular asset has changed so that it only has to regenerate assets that will actually be different. Some googling has told me that…
SilentSin
  • 1,026
  • 9
  • 18
1
vote
1 answer

How to add data directory in connection string to deploy application on client machine?

I created an windows form application in c# during development i used following connection string and it works fine
Waqas
  • 847
  • 4
  • 14
  • 36
1
vote
1 answer

C# CompilerParameters.OutputAssembly causes application to restart

I am developing an ASP.Net C# application, in which users may compile piece of code on the fly. I'm using CSharpCodeProvider in this case. The problem that I just encountered, was that somehow the CompilerParameter.OutputAssembly causes the…
1
vote
1 answer

Insert/Inject an Object to string code

I have a C# code generated dynamically using System.CodeDom.CodeCompileUnit in runtime, I compile it using Microsoft.CSharp.CSharpCodeProvider , What I want is to insert an already defined & initialized Variable (an ArrayList) to this string so I…
Vahid2023
  • 863
  • 3
  • 11
  • 33
1
vote
1 answer

Detect modification in automated generated c# source code with csharpcodeprovider

I need detect when exist any modification in c# code automaticaly generate with CSharpCodeProvider after generation. Exist any build in solution? I can make my solution (adding a CRC in a comment)... but I search a built in solution provide by .NET…
Victor Sanchez
  • 583
  • 9
  • 28
1
vote
1 answer

CodeDom reference to COM

I'm currently working on a program that uses the CSharpCodeProvider to generate an executable. And I need to add a reference to a COM-Lib ("Windows Script Host Model" (wshom.ocx)). This file is located in the sysWOW64-Path. Every time I try to…
chesta
  • 315
  • 3
  • 13