good morning!
using operators and conditional with reflection or Reflection.Emit?
tanks
good morning!
using operators and conditional with reflection or Reflection.Emit?
tanks
I'm hitting the problem described here. However, I don't see any way with MailMessage to set the ordering of the content of the email.
How can I fix this?
MailMessage mail = new MailMessage(new MailAddress(emailTempKeysFrom, "Windward Studios"), new MailAddress(to[0], pur.Account.Name)); mail.Body = txt; AlternateView htmlView = AlternateView.CreateAlternateViewFromString(html, null, MediaTypeNames.Text.Html); int num = 0; foreach (MemoryStream mem in imagesTempKeys) { mem.Position = 0; LinkedResource res = new LinkedResource(mem); res.ContentId = "image" + num; res.TransferEncoding = TransferEncoding.Base64; htmlView.LinkedResources.Add(res); num++; } mail.AlternateViews.Add(htmlView); mailObj.Send(mail);
thanks - dave
What we did for the last 6 months - Made the world's coolest reporting & docgen system even more amazing
hallo, everyone,
we have a Desktop-App (vb.net), and need open Excel from program, and we just used
xlsWorkbook = CType(System.Runtime.InteropServices.Marshal.BindToMoniker(filePath), Excel.Workbook)
xlsApp = CType(xlsWorkbook.Parent, Excel.Application)
and it works fine except by one user,
and we tried
xlsApp = New Excel.Application or
xlsApp = CType(CreateObject("Excel.Application"), Excel.Application)
and it cant work with his computer, by other users are ok.
i think its nothing to do with our code, just one com-component in his computer is missing, such like interop.excel.dll or sth else.
anyone know this? can anyone help?
thanks a lot!
Hi,
I got this:
To overcome this, you need to iterate through the source array and add each value to the SqlParameterCollection collection string[] source = Convert.ToString(cboToCountry.EditValue).Split(new char[] { cboToCountry.Properties.SeparatorChar }); StringBuilder sb = new StringBuilder(); foreach (string s in source) sql_command.Parameters.AddWithValue("param_country", s.Trim());
not sure how can I use the SqlParameterCollection.
Kindly help..
here is my code:
sql_connection = new MySqlConnection(serverClass.connectionstring("BlueFile", "BlueFile", "Server")); sql_connection.Open(); sql_command = new MySqlCommand("sp_populate_memo_country_companies", sql_connection); sql_command.CommandType = CommandType.StoredProcedure; // sql_command.Parameters.AddWithValue("param_country", country_codes(Convert.ToString(cboToCountry.EditValue))).MySqlDbType = MySqlDbType.VarChar; string[] source = Convert.ToString(cboToCountry.EditValue).Split(new char[] { cboToCountry.Properties.SeparatorChar }); StringBuilder sb = new StringBuilder(); foreach (string s in source) { sql_command.Parameters.AddWithValue("param_country", s.Trim()).MySqlDbType = MySqlDbType.VarChar; }
Thanks,
I have recently been looking into NLua for C# inb visual studio
however when I compile can run it I get the error "the type or namespace name KeraLua could not be found"
can someone tell me what this means
NLua seems to come with a demo project but I want to have only the API in my project, not the demo projects.
I believe the reverse video printing / capReverse property was added back in the release UPOS 1.6 and currently i am using Microsoft pos for .Net sdk version 1.12 and 1.14 and unable to find the the CapReverse property in the PrinterProperty class. can any one tell how this feature can be implemented. ?
The link above describes the pos printer properties , but it does not include anything about the CapReverse
ss
I have used the EL 5.0 to create the log. The log is created but its writing log in two files instead of one.
Here is name of first file name: Policy.txt
Second file name: 28afdf13-db29-453c-8a85-2684e9895353Policy.txt
Business want just one log file daily from midnight.
Here is log configuration.
<add name="Policy Flat File" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.RollingFlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" fileName="C:\LOGS\Policy.txt" header="" footer="" formatter="MAO-Privacy-Policy" rollFileExistsBehavior="Increment" rollInterval="Midnight" timeStampPattern="yyyy-MM-dd" rollSizeKB="10000" maxArchivedFiles="30" />
Please help to fix this issue.
Hello,
I am developing ASP.NET application and I want to load html from another site which uses AJAX for loading data from the server and insert it to HTML after. How to get final HTML source code after javascript execution?
Thank you for your time!
I can't help but feel like this is a bug:
void Main() { typeof(Test).GetProperty("TestString").GetCustomAttributes().Dump(); //dumps 1 item typeof(Test).GetProperty("TestString").GetCustomAttributes(inherit:true).Dump(); // dumps 0 items typeof(Test).GetProperty("TestString").GetCustomAttributes(inherit:false).Dump(); // dumps 0 items } // Define other methods and classes here class TestBase { [TestAttribute] public virtual string TestString {get;set; } } class Test : TestBase { public override string TestString {get;set; } } [AttributeUsage(AttributeTargets.Property, Inherited = true)] class TestAttribute : Attribute {}
Are property attributes even supposed to be inheritable? ReSharper doesn't seem to think so, giving you a warning that "Inherited = true" only applies to AttributeTargets.Class and AttributeTargets.Method, and either does GetCustomAttributes(bool inherit). Why would the parameterless version return the attribute?
Next up: why are all the GetRuntimeXXX() methods extensions on Type and not extensions on TypeInfo? I thought the whole point of the reflection API redesign was to make Type just a reference to a type, and TypeInfo to require a load and contain all the actual type shape and information. Doesn't this design fly in the face of this distinction? I don't understand why they aren't just plain methods on TypeInfo instead of extensions on Type.
Why does TypeInfo inherit from Type in .NET but not in .NET Core and UWP? This causes confusion because all the extensions mentioned above are now available on both Type and TypeInfo on .NET, and introduces more API differences between the platforms. Now you need to go to TypeInfo to get some stuff, while other stuff you can just grab from Type but it will still cause an assembly load, and stuff is just all over the place. This is further confused by the fact that the API docs for .NET Core show that the class declaration for TypeInfo DOES in fact inherit from Type. Whaaaa??
Why does GetRuntimeProperties() return non-public members but GetRuntimeProperty(name) doesn't? This completely violates the principle of least surprise. This would almost be forgivable if the difference was documented in the method docs but it isn't.
Is there actually a point to the GetRuntimeXXX? It seems to me that GetProperties and GetProperty are available everywhere. When should you pick one over the other now?
There are more things that I can't remember off the top of my head but this is honestly the most botched API refresh I've seen come out of Microsoft. The only other thing that comes close is the mess of inconsistencies between generic and non-generic collection interfaces/classes. Writing a portable library that heavily depends on reflection has been quite the exercise in patience these last couple months.
I really wish there was an opportunity to do a "clean break" where all the past mistakes of the framework could be cleaned up, especially the collection classes/interfaces situation because those are used all the time. But I'm guessing that's never going to happen...I was hoping .NET Core was going to be that clean break and clean everything up in a sensible way but it didn't :(
I am populating an ObservableCollection<T> where T is a simple model. One of the properties in my model is a byte[]. The ObservableCollection<T> is refreshed often, using these steps:
Problem: The memory consumption grows everytime the observable collection is repopulated.
My questions are:
Thanks in advance for your help!
Hello, I'm working on a wcf service and trying to create a chart serverside and save it as image so that I can send the image url to external users. Here is the complete code:
var chart = new System.Web.UI.DataVisualization.Charting.Chart(); chart.EnableViewState = false; chart.Titles.Add(new System.Web.UI.DataVisualization.Charting.Title()); chart.Titles[0].Text = "Cash Balance Comparison"; chart.Titles[0].Alignment = System.Drawing.ContentAlignment.TopCenter; chart.Visible = true; chart.Legends.Add("Legend1"); var series = chart.Series.Add("School 1"); series.ChartType = System.Web.UI.DataVisualization.Charting.SeriesChartType.RangeColumn; series.Points.AddXY("dept 1", 12345); series.Points.AddXY("dept 2", 345); series.Points.AddXY("dept 3", 345); series.Points.AddXY("dept 4", 5656); series = chart.Series.Add("School 2"); series.ChartType = System.Web.UI.DataVisualization.Charting.SeriesChartType.RangeColumn; series.Points.AddXY("dept 1", 54345); series.Points.AddXY("dept 2", 444); series.Points.AddXY("dept 3", 54345); series.Points.AddXY("dept 4", 9090); series = chart.Series.Add("School 3"); series.ChartType = System.Web.UI.DataVisualization.Charting.SeriesChartType.RangeColumn; series.Points.AddXY("dept 1", 239); series.Points.AddXY("dept 2", 2397); series.Points.AddXY("dept 3", 23237); series.Points.AddXY("dept 4", 2234487); chart.Legends[0].Docking = System.Web.UI.DataVisualization.Charting.Docking.Bottom; chart.Legends[0].TitleAlignment = System.Drawing.StringAlignment.Center; chart.Legends[0].Alignment = System.Drawing.StringAlignment.Center; chart.RenderType = System.Web.UI.DataVisualization.Charting.RenderType.ImageTag; string path = @"C:\temp\Charts\test.png"; chart.ImageLocation = path; chart.SaveImage(path, System.Web.UI.DataVisualization.Charting.ChartImageFormat.Png); chart.Dispose(); chart = null; return path;
It saves an image with a chart title, but doesn't contain anything else. Can someone please let me know why its not working?
Any help will be highly appreciated.
Thanks.
I have a lot of PCL libraries targeting .NET Framework 4.5.1 and Windows Universal I'd like to upgrade to 4.6. Unfortunately, some of them rely on MEF2 (the package from NuGet: microsoft.composition), which targets 4.5 only. Yet, this lightweight version seems to be the most modern of the MEF releases. Is there any way I can use this package in these PCLs, or should I stick with 4.5 and wait for a hopefully upgrade of that package? According to this post (http://stackoverflow.com/questions/28801312/is-there-a-replacement-for-mef-in-net-core-or-asp-net-5), it seems that the MEF2 package is effectively usable even in .NET Core (yet, the proposed solution for using that package in .NET Core libraries does not seem to work).
You can easily reproduce the issue as follows: using VS2015 update 3, create a new PCL library project (.NET Framework: 4.6.2, Class Library (Portable), accepting all the default targets: .NET Framework 4.6, Windows Universal 10.0). Then try to install MEF2 via its NuGet package: install-package microsoft.composition. NuGet will fail installing the package, telling that package is not compatible with .NETStandard, Version=v1.3. The package rather supports portable-net45+win8+wp8+wpa81 (.NETPortable,Version=v0.0,Profile=Profile259).
i am trying to send a ZPL (Zebra Programming Language) command to my Zebra GX420t printer to check its status if it available, offline, ready or pause etc. i can send a command to write to printer but please tell me how i can read response from the printer ?
is there any way to send zpl through c# and then read the resposne.
i have alreay tried the link below but my ReadPrinter function is not returning any data in the "out" parameter and the method always return false:
https://msdn.microsoft.com/en-us/library/windows/desktop/dd162895(v=vs.85).aspx
http://stackoverflow.com/questions/25669403/how-to-send-a-raw-zpl-to-zebra-printer-using-c-sharp-via-usb?rq=1
http://stackoverflow.com/questions/2044676/net-code-to-send-zpl-to-zebra-printers
my code is as follows:
/////////To send data to printer i have used
string s = "^XA~HQES^XZ\n";
var bytes = Encoding.ASCII.GetBytes(s);
RawPrinterHelper.SendStringToPrinter("ZDesigner GX420t (Copy 1)", s);
////////////////////////////////////////////////////////////////////////////////////
//////This is my method to send request and then get response
public static bool SendBytesToPrinter(string szPrinterName, IntPtr pBytes, Int32 dwCount)
{
Int32 dwError = 0, dwWritten = 0;
IntPtr hPrinter = new IntPtr(0);
DOCINFOA di = new DOCINFOA();
bool bSuccess = false; // Assume failure unless you specifically succeed.
di.pDocName = "MTOlive label";
di.pDataType = "RAW";
// Open the printer.
if (OpenPrinter(szPrinterName.Normalize(), out hPrinter, IntPtr.Zero))
{
// Start a document.
if (StartDocPrinter(hPrinter, 1, di))
{
// Start a page.
if (StartPagePrinter(hPrinter))
{
// Write your bytes.
bSuccess = RawPrinterHelper.WritePrinter(hPrinter, pBytes, dwCount, out dwWritten);
StringBuilder sbData = new StringBuilder();
bool aSuccess = ReadPrinter(hPrinter, out sbData, dwWritten, out dwWritten);
EndPagePrinter(hPrinter);
}
EndDocPrinter(hPrinter);
}
ClosePrinter(hPrinter);
}
// If you did not succeed, GetLastError may give more information
// about why not.
if (bSuccess == false)
{
dwError = Marshal.GetLastWin32Error();
}
return bSuccess;
}
/////////////////////////////////////