Telerik WinForm problems in Windows Server 2008 R2 - c#

I build wcf ,and it run's on Windows Server 2008 R2.Now i updated my program , and add Scheduler(telerik).
After this my aplication is start's to crash.
Do any one know how to fix it?
Here my code that works
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.IO;
using System.Linq;
using System.ServiceModel;
using System.Threading;
using System.Windows.Forms;
namespace WindowsFormsApplication
{
static class Program
{
// public static SchedulerForm Scheduler = new SchedulerForm(); here Scheduler disabled
private static NotifyIcon trayIcon;
static void Main()
{
using (ServiceHost host = new ServiceHost(typeof(SimpleService.SimpleService)))
{
host.Open();
SysTrayApp();
Application.Run();
}
}
public static void SysTrayApp()
{
/* tmNowActions = new ContextMenu();
tmNowActions.MenuItems.Add("....
my other function (not important)
*/
// Scheduler.ShowDialog();
}
}
}
And here after i remove comments and enable scheduler
namespace WindowsFormsApplication
{
static class Program
{
public static SchedulerForm Scheduler = new SchedulerForm();
private static NotifyIcon trayIcon;
static void Main()
{
using (ServiceHost host = new ServiceHost(typeof(SimpleService.SimpleService)))
{
host.Open();
SysTrayApp();
Application.Run();
}
}
public static void SysTrayApp()
{
/* tmNowActions = new ContextMenu();
tmNowActions.MenuItems.Add("....
my other function (not important)
*/
Scheduler.ShowDialog();
}
}
}
After this my aplication is crashed
Here the image from win server 2008 R2
Do any one know how to fix it?
UPDATE
I found that i was missing some telerik dll's,after i add them i get a new error.
If i will make empty WinForm all works fine,and i will see empty form ,but if i add telerik element(Scheduler in my case),i will get this error
Here another error that says i am missing Scheduler version,but you can see the dll and properties of this dll,and it is there it is not missing.

I resolved this problem like this:
1:Clean project and delete old files from Degub/bin.
2:Make sure all telerik dll's have the same version(end's .20 or .40) !!IMPORTANT!!.
3:In Telerik dll's click properties, and then make Copy Local = true !!IMPORTANT!!.
4:Rebuild the project.
After all this steps all start to work.

Related

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

I'm trying to make a web browser application, but when I relaunch Visual Studio Community 2019, it shows me about 500 errors such as The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?).
I tried reloading Visual Studio Community 2019 a few times, but still doesn't work either.
Some project infos:
Target framework: .NET Framework 4.8
NuGet Packages used: EasyTabs, CefSharp.WinForm
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using CefSharp;
using CefSharp.WinForms;
using EasyTabs;
Just before I post the question, I found out that you need to use .NET Framework 4.7.2 in order to fix the problem.
So you're using easy tabs, I have the code for you. create new windows form project, in the project create another form and rename it AppContainer with the caps and everything, then open the app container with framework 4.7.2 then type in C# code
namespace YOUR_PROGRAM_NAME_HERE
{
public partial class AppContainer : TitleBarTabs
{
public AppContainer()
{
InitializeComponent();
AeroPeekEnabled = true;
TabRenderer = new ChromeTabRenderer(this);
}
// Handle the method CreateTab that allows the user to create a new Tab
// on your app when clicking
public override TitleBarTab CreateTab()
{
return new TitleBarTab(this)
{
// The content will be an instance of another Form
// In our example, we will create a new instance of the Form1
Content = new Form1
{
Text = "New Tab"
}
};
}
// The rest of the events in your app here if you need to .....
}
}
also at the top of where it says using please type using EasyTabs and then type using CefSharp. basically every package code you use you need to refer to that package then add a subtitle for Browser. Next Open Form1.cs and type this Code.
// 2. Important: Declare ParentTabs
protected TitleBarTabs ParentTabs
{
get
{
return (ParentForm as TitleBarTabs);
}
}
type this where the namespace of your code is For example.
namespace YOUR_PROGRAM_NAME_HERE
{
public partial class Form1 : Form
{
// 2. Important: Declare ParentTabs
protected TitleBarTabs ParentTabs
{
get
{
return (ParentForm as TitleBarTabs);
}
}
public object HTMLcodeec { get; }
public Form1()
{
InitializeComponent();
}
now co into the program.cs file in your solution explorer and click on it one you do you need to type the following code
namespace YOUR_PROGRAM_NAME_HERE
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
AppContainer container = new AppContainer();
// Add the initial Tab
container.Tabs.Add(
// Our First Tab created by default in the Application will have as
content the Form1
new TitleBarTab(container)
{
Content = new Form1
{
Text = "New Tab"
}
}
);
// Set initial tab the first one
container.SelectedTabIndex = 0;
// Create tabs and start application
TitleBarTabsApplicationContext applicationContext = new
TitleBarTabsApplicationContext();
applicationContext.Start(container);
Application.Run(applicationContext);
}
}
}
Now open Form1.cs and go to Form1. Load Event and at the top of it type
ChromiumWebBrowser Browser;
private void Form1_Load(object sender, EventArgs e)
{
CefSettings settings = new CefSettings();
//Initialize
CefSharpSettings.LegacyJavascriptBindingEnabled = true; // Enable Register JS Object, -- RegisterAsyncJsObject, RegisterJsObject allow
settings.CachePath = "cache";
settings.CefCommandLineArgs.Add("enable-media-stream", "1"); //Enable WebRTC4
settings.CefCommandLineArgs.Add("disable-gpu", "1");
settings.CefCommandLineArgs.Add("disable-gpu-compositing", "1");
BrowserSettings browserSettings = new BrowserSettings
{
FileAccessFromFileUrls = CefState.Enabled,
UniversalAccessFromFileUrls = CefState.Enabled,
WebSecurity = CefState.Enabled,
WebGl = CefState.Enabled,
BackgroundColor = (uint)CefState.Enabled,
};
Browser = new ChromiumWebBrowser(AddressText.Text);
this.pContainer.Controls.Add(Browser);
Browser.DownloadHandler = new DownloadHandler();
Browser.Dock = DockStyle.Fill;
Browser.Load("https://ask.com/");
this.AcceptButton = this.NavigateToURL;
Browser.AddressChanged += Browser_AddressChanged;
Browser.TitleChanged += Browser_TitleChanged;
}
before you don any of this please download cefsharp and easy tabs to your project
if you want to see my Browser project I build Go to https://cleverdamontoutube.wixsite.com/downloaddamonic and you can see what iv done
it is a .exe file you can download "if you need any more help subscrie to my youtube channel because ill be making a video on this topic shorrtly"

How to apply Windows taskbar changes without restarting Explorer in C#?

This is my current code, it works but it restarts the Explorer process and that's kinda weird.
using System;
using System.Diagnostics;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Win32;
namespace MyApp
{
class Program
{
static async Task Main(string[] args)
{
ShowSmallTaskbarIcons();
// ShowLargeTaskbarIcons();
Console.WriteLine("Press a key to exit...");
Console.ReadKey();
}
static void ShowSmallTaskbarIcons()
{
Registry.SetValue(#"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced", "TaskbarSmallIcons", "1", RegistryValueKind.DWord);
RefreshExplorer();
}
static void ShowLargeTaskbarIcons()
{
var key = Registry.CurrentUser.OpenSubKey(#"Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced", writable: true);
key.DeleteValue("TaskbarSmallIcons", throwOnMissingValue: false);
key.Close();
RefreshExplorer();
}
static void RefreshExplorer()
{
Process.Start("taskkill.exe", "/f /im explorer.exe");
Thread.Sleep(2000);
Process.Start("explorer.exe");
Thread.Sleep(10000);
}
}
}
I would like to do the same as with the "Use small taskbar buttons" toggle switch from Settings.
How to do the same with C#?
How to change Windows 10 taskbar icon size programmatically
This post has an example about how to send WM_SETTINGCHANGE message in c++.
However, there is no easy way to do it in c# wrapped function. You have to do it through p/invoke
Following post will help you do it in c#
convert C++ code to C#: SendMessageTimeout()

Running Python Script/application in Windows Phone 8

I want to run the Skeinforge slicer program written in Python inside my Windows Phone 8 C# application. I have determined that I should probably use IronPython to do this, I have already determined that I can run Skeinforge inside the ipy.exe terminal I got when I installed IronPython. My problem though is that I am struggling to figure out how to host and run a Python script with IronPython inside Windows Phone 8. I have also already managed to get a simple hello world script running inside a Desktop Windows Forms application that transfers the applications console output to the Debug console with the following code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Diagnostics;
using System.IO;
using IronPython.Hosting;
using Microsoft.Scripting.Hosting;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
DebugWriter debugW = new DebugWriter();
Console.SetOut(debugW);
}
private void button1_Click(object sender, EventArgs e)
{
TextWriter tw = new StreamWriter("Test.py");
tw.Write(scriptBox.Text);
tw.Close();
try
{
var ipy = Python.CreateRuntime();
dynamic test = ipy.UseFile("Test.py");
}
catch (Exception ex)
{
Debug.WriteLine("Error: " + ex.Message);
}
}
}
}
And this is the DebugWriter:
class DebugWriter : TextWriter
{
private StringBuilder content = new StringBuilder();
public DebugWriter()
{
Debug.WriteLine("Writing console to debug");
}
public override void Write(char value)
{
base.Write(value);
if (value == '\n')
{
Debug.WriteLine(content.ToString());
content = new StringBuilder();
}
else
{
content.Append(value);
}
}
public override Encoding Encoding
{
get { return System.Text.Encoding.UTF8; }
}
}
I have no idea how to even add the IronPython libraries to my Windows Phone 8 application though as the standard libraries won't import. I have though tried compiling the apparently now defunct Windows Phone 7 libraries with the master source code and I can import these libraries, but I get absolutely no response on the debug terminal when I try to run my hello world script.
Do any of you have any idea how to get this woring in Windows Phone 8, if you know how to do this in Windows 8/Metro/RT then that would also probably work for WP8.
UPDATE:
I have looked at the debug output again and I seem to get this error when trying to use the WP7 libraries to run a hello world script:
A first chance exception of type 'System.NotImplementedException' occurred in Microsoft.Scripting.DLL
Error: The method or operation is not implemented.
I managed to get Skeinforge running on a modified version of IPY. You can get the source for my application here: http://skeinforgewp8.codeplex.com/

How to Call VSTS Coded Ui Scripts to QTP?

I am trying to execute my Coded UI Scripts on QTP.
First I created a dll for my Coded UI Project later I am able to access the methods from that dll but i am not able to access Coded UI testing methods.
Example:
the below script is in C# in VSTS
namespace TestProject1
{
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Input;
using System.Windows.Forms;
using System.CodeDom.Compiler;
using System.Text.RegularExpressions;
using Microsoft.VisualStudio.TestTools.UITest.Extension;
using Microsoft.VisualStudio.TestTools.UITesting;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Keyboard = Microsoft.VisualStudio.TestTools.UITesting.Keyboard;
using Mouse = Microsoft.VisualStudio.TestTools.UITesting.Mouse;
using MouseButtons = System.Windows.Forms.MouseButtons;
using Microsoft.VisualStudio.TestTools.UITesting.WinControls;
using Microsoft.VisualStudio.TestTools.UITesting.HtmlControls;
using Microsoft.VisualStudio.TestTools.UITesting.WpfControls;
public partial class UIMap
{
public int MyInteger()
{
return 9;
}
public string testDll()
{
return "Test DLL Factory";
}
public void add1()
{
MessageBox.Show("Sravan");
}
public void DeletePhoto()
{
WinWindow window = new WinWindow();
window.SearchProperties[WinWindow.PropertyNames.Name] = "Cyramed";
window.SearchProperties.Add(new PropertyExpression(WinWindow.PropertyNames.ClassName, "WindowsForms10.Window", PropertyExpressionOperator.Contains));
WinWindow c_window = new WinWindow(window);
c_window.SearchProperties[WinWindow.PropertyNames.ControlName] = "PICTUREBOX1";
c_window.WindowTitles.Add("Cyramed");
c_window.DrawHighlight();
WinClient c_client = new WinClient(c_window);
c_client.WindowTitles.Add("Cyramed");
c_client.DrawHighlight();
Mouse.Click(c_client, MouseButtons.Right);
Keyboard.SendKeys("{DOWN}");
Keyboard.SendKeys("{DOWN}");
Keyboard.SendKeys("{DOWN}");
Keyboard.SendKeys("{ENTER}");
}
}
}
I can call MyInteger and testDll methods but when I call the DeletePhoto method it throws an error: "Could not load file or assembly 'Microsoft.VisualStudio.TestTools.UITesting, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified."
My primary concern: I want to execute Coded UI scripts on QTP too.
You'll likely have to install Visual Studio Test Agents on your QTP test agents. These will drop the binaries on the machine.
VS 2010 Test Agents
VS 2010 SP1

How could Python access C# variable?

I am using visual studio 2010 AddIn template for ArcGis 10.0. Since I already wrote a python code for ArcGIS processing. I would like to insert a button into the ArcMap desktop command bar running this python code. Following is my simplized c# code and the beginning of python code for your reference:
c# code:
using System;
using System.Windows.Forms;
using System.Collections.Generic;
using System.Text;
using System.IO;
using Microsoft.VisualBasic;
namespace CallPython
{
public class CallPython : ESRI.ArcGIS.Desktop.AddIns.Button
{
public CallPython()
{
}
public string inputName()
{
string inputNames;
inputNames = "cavert.shp";
return inputNames;
}
protected override void OnClick()
{
inputName();
System.Diagnostics.Process.Start(
"D:\\From2\\BCAP\\python\\scripts\\trans5.py");
}
protected override void OnUpdate()
{
Enabled = ArcMap.Application != null;
}
}
}
Python code:
import arcpy
import os, win32com.client
from arcpy import env
arcpy.env.overwriteOutput = True
# Set environment settings
env.workspace = "D:/BCAP/trans/tempt/"
# Set local variables
vs_method_source = os.path.abspath("D:/Users/mar/CallPython/CallPython.cs")
vs_file_name = os.path.abspath("D:/Users/mar/CallPython/CallPython.sln")
vs = win32com.client.Dispatch("VisualStudio.DTE.7.1")
doc_template = vs.Documents.Open(vs_file_name)
mm = doc_template.CallPython.inputName() #CallPython is namespace, inputName is method
The last line of python code is the problem. I know it is definitely not right, but didn't know how to access C# namespace, class, then method from python.

Categories

Resources