I have a Xamarin binding project that's been used for some time. I recently went to update it a little and get it hooked up to our CI server, and for some reason I find that when I build it, it seems to stop halfway through generating the code, and then try to compile it. I say this because the last few lines of Messaging.g.cs look like this:
[DllImport (LIBOBJC_DYLIB, EntryPoint="objc_msgSendSuper")]
public extern static bool bool_objc_msgSendSuper_IntPtr_UInt64_ref_IntPtr (IntPtr receiver, IntPtr selector, IntPtr arg1, global::System.UInt64 arg2, ref IntPtr arg3);
[DllImport (LIBOBJC_DYLIB, EntryPoint="objc_msgSend")]
public extern static bool bool_objc_msgSend_SByte_ref_IntPtr (IntPtr receiver, IntPtr
The file literally ends on that IntPtr, midway through a method signature. The file is 523 lines, 53248 characters, so I can't see an obvious filesize limit it's hitting, and it used to work with no problems. If I move the files across the the Mac that I'm using as a build agent and open the solution in Xamarin Studio, it builds just fine.
I'm using Visual Studio 2015 Update 1, with Xamarin 4.0.1.89, Xamarin.iOS 9.4.1.24.
Does anyone know what can cause this?
Related
I wan to use the STAThread attribute on my the main thread of my program. However, Visual Studio says it cannot find it. I have tried references necessary assemblies and using proper namespace, but it just can't find it.
Edit:
I have been able to get to work successfully after manually creating a thread with the
ApartmentState to STA. I think this is the equivalent to setting the thread, be it the main thread, but not exactly because i'm creating another thread. Anyone have another way to do this.
Here is the code:
void threadStart ()
{
Application::Run (gcnew GraphicsForm());
}
[System::STAThread] // This will not work!
int main(array<System::String ^> ^args)
{
Thread ^t = gcnew Thread(gcnew ThreadStart (threadStart));
t->ApartmentState = ApartmentState::STA;
t->Start();
return 0;
}
When I create a new C++/CLI project in Visual Studio 2012 with only a single main() function and then add [System::STAThread] in front of main(), it compiles and runs without a problem. To me, this means that it is most likely a settings difference between projects.
My recommendation is to do the same thing. Create a new C++/CLI project, add [System::STAThread] and see if it has any issues. If not, then you're at the point of checking the differences between the two projects to determine why one works properly and the other is giving you an error.
I am working on a project that creates a reporting database by loading data from an AS400 into SQL Server 2012 Express (just FYI - I do not have sql agent or sql profiler). I downloaded sql server data tools with the SSIS designer and created a couple of data loading packages within the same solution. I have researched running SSIS packages using the DTExec utility, and for the most part it worked fine, however, I was not able to log any of the runtime data to a log table (only the text file log worked), and for some reason the send emails tasks didn't send emails when run through DTExec. Both of these things worked fine when running the packages directly in VS Shell.
While trying to troubleshoot these issues, I realized that I do not actually have integration services installed on my machine - just the designer. I will not be able to get integration services (soon, at least) so I would like to figure out how to launch VS Shell, validate, build and execute my SSIS load packages - not using the DTExec utility, but actually launching in the VS Shell using Windows Scheduler.
I know that to launch the program itself, I would just schedule devenv.exe. But what arguments do I use to validate, build and execute the packages using this method. The only thing I can find about executing packages involves using the utility, and assumes that the user has SSIS installed, not just the designer.
Now, if worse comes to worse I can just execute the load packages and then create some sql queries to pull together the row counts and other stuff I will need to audit the data, but it seems like there should be a way to do what I want to do.
There's a reason you're not able to run an SSIS package outside of BIDS/SSDT/Visual Studio and it's called licensing.
With the 2012 release of SQL Server, you're free to develop SSIS packages to your heart's content. However, to get them to run outside of Visual Studio means you need to have installed SQL Server on the invoking machine. Even though it's "just integration services", that's a SQL Server installation and thus a license is required. A developer edition license of SQL Server is cheap: ~50 USD per user. However, since it sounds like you're making a "productionalized" version, you're going to need a Standard Edition or Enterprise Edition, depending on the features used in SSIS. SE or EE is not cheap and with the change to licensing with the 2012 release (per core vs per socket), it's gotten more precious.
You're looking for a technical solution and if you find one, you're likely going to be in violation of licensing.
You can use AutoIT to script GUI applications:
http://www.autoitscript.com/site/autoit/
I managed to figure out how to launch VS using the windows scheduler:
create a task
go to actions, edit
In the program/script box enter the path to devenv.exe (using double quotes) - "C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\devenv.exe"
In Add arguments enter devenv /runexit /project [project name] "\fileserver\path[solution name].sln"
You can use other switches for arguments: http://msdn.microsoft.com/en-us/library/xee0c8y7.aspx
The only thing is that because it is running in visual studio (at least for me) is that it runs in debug mode, so you have to click stop to stop debugging. So in my case, I used the runexit switch, which is supposed to close VS when the package is complete. It only closed after I clicked stop. I tried using the /command switch to execute a stop debugging command (http://msdn.microsoft.com/en-us/library/c3a0kd3x.aspx) Debug.StopDebugging, but it didn't seem to work.
I used the run flag in task scheduler and I was able to get the the debugger to automatically stop by taking advantage of user32.dll via a script. Basically I send the close command message and a button click to the ok on the close dialog. Below is my cookie cutter task I put at the end of my projects... If you just want to stop without exit you could probably just send shift+f5 too.
private static string project = "MyProjectName";
[DllImportAttribute("User32.dll")]
private static extern int FindWindow(String ClassName, String WindowName);
[DllImport("user32.dll", CharSet = CharSet.Auto)]
static extern IntPtr SendMessage(int hWnd, UInt32 Msg, IntPtr wParam, IntPtr lParam);
[DllImport("user32.dll", SetLastError = true)]
public static extern int FindWindowEx(int parentHandle, IntPtr childAfter, string className, string windowTitle);
const UInt32 WM_CLOSE = 0x0010;
private const int BN_CLICKED = 245;
/// <summary>
/// This method is called when this script task executes in the control flow.
/// Before returning from this method, set the value of Dts.TaskResult to indicate success or failure.
/// To open Help, press F1.
/// </summary>
public void Main()
{
int hwndChild = 0;
int hWnd = FindWindow(null, project + " (Running) - Microsoft Visual Studio (Administrator)");
if (hWnd == 0)
hWnd = FindWindow(null, project + " (Running) - Microsoft Visual Studio");
if (hWnd == 0)
hWnd = FindWindow(null, project + " - Microsoft Visual Studio");
if (hWnd > 0)
{
SendMessage(hWnd, WM_CLOSE, IntPtr.Zero, IntPtr.Zero);
while (hwndChild == 0)
{
hWnd = FindWindow(null, "Microsoft Visual Studio");
hwndChild = FindWindowEx(hWnd, IntPtr.Zero, "Button", "&Yes");
if (hwndChild == 0)
hwndChild = FindWindowEx(hWnd, IntPtr.Zero, "Button", "Yes");
SendMessage(hwndChild, BN_CLICKED, IntPtr.Zero, IntPtr.Zero);
System.Threading.Thread.Sleep(500);
System.Windows.Forms.Application.DoEvents();
}
}
Dts.TaskResult = (int)ScriptResults.Success;
}
We're having an issue where trying to open specific designer files within Visual Studio (either 2010 or 2012) will cause it to crash unrecoverably ('Visual Studio has stopped working').
Attaching a debugger to the process when this is attempted throws a System.NullReferenceException, with stack trace:
at System.Windows.Forms.NativeWindow.AddWindowToTable(IntPtr handle, NativeWindow window)
at System.Windows.Forms.NativeWindow.AssignHandle(IntPtr handle, Boolean assignUniqueID)
at System.Windows.Forms.Design.ControlDesigner.ChildSubClass..ctor(ControlDesigner designer, IntPtr hwnd)
at System.Windows.Forms.Design.ControlDesigner.HookChildHandles(IntPtr firstChild)
at System.Windows.Forms.Design.ControlDesigner.HookChildControls(Control firstChild)
at System.Windows.Forms.Design.ControlDesigner.HookChildControls(Control firstChild)
at System.Windows.Forms.Design.ControlDesigner.HookChildControls(Control firstChild)
at System.Windows.Forms.Design.ControlDesigner.HookChildControls(Control firstChild)
at System.Windows.Forms.Design.ControlDesigner.OnHandleChange()
at System.Windows.Forms.Design.ControlDesigner.DesignerWindowTarget.OnHandleChange(IntPtr newHandle)
at System.Windows.Forms.Control.ControlNativeWindow.OnHandleChange()
at System.Windows.Forms.NativeWindow.AssignHandle(IntPtr handle, Boolean assignUniqueID)
at System.Windows.Forms.NativeWindow.AssignHandle(IntPtr handle)
at System.Windows.Forms.NativeWindow.WindowClass.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
This issue appears consistently on the development boxes that we have updated to Windows 8 Enterprise (and now use SSDs). The older boxes on Windows 7 Professional consistently do not exhibit this behaviour. The issue also only seems to occur on specific designer files, though it is not clear yet why.
Does anyone have any suggestions for resolving this, or investigating further?
Never fully resolved this issue, but did engineer a workaround. There is more info (from MS) in the bug report I submitted here:
http://connect.microsoft.com/VisualStudio/feedback/details/802088/designer-file-causing-crash-since-update-to-windows-8
In summary, the MS team suggested this was a "..crash when static initialization for one of the controls was failing"
Through trial and error we narrowed down the issue to identify the control that was causing the issue, and then minimised the initialisation it was performing (but only in design time)
To minimise initialisation we added a property to check if the control was being used in designer:
private bool IsDesignerHosted
{
get
{
if (LicenseManager.UsageMode == LicenseUsageMode.Designtime) return true;
Control ctrl = this;
while (ctrl != null)
{
if ((ctrl.Site != null) && ctrl.Site.DesignMode) return true;
ctrl = ctrl.Parent;
}
return false;
}
}
.. then use this property to prevent activity on the control when in design time.
After I converted a solution to Visual Studio 2012 (previous version was Visual Studio 2010) I tried to run the unit tests in the solution. Now the testrunner crashes before executing a single test. I get a rather general error message. If I choose to debug Visual Studio I get the following stack trace:
Microsoft.VisualStudio.QualityTools.TMI.dll!Microsoft.VisualStudio.TestTools.TestManagement.AssemblyKeyExtractor.ExtractPublicKeyFromKeyFile(string keyFile, out bool isPublicKey)
[Managed to Native Transition]
Microsoft.VisualStudio.QualityTools.TMI.dll!Microsoft.VisualStudio.TestTools.TestManagement.PublicKeyHolder.this[string].get(string file)
Microsoft.VisualStudio.QualityTools.TMI.dll!Microsoft.VisualStudio.TestTools.TestManagement.DeploymentHelper.GetPublicKey(string keyFile, Microsoft.VisualStudio.TestTools.TestManagement.PublicKeyHolder publicKeyHolder)
Microsoft.VisualStudio.QualityTools.TMI.dll!Microsoft.VisualStudio.TestTools.TestManagement.DeploymentHelper.ProcessCodeCoverageItemsForDeployment(System.Collections.Generic.List<Microsoft.VisualStudio.TestTools.TestManagement.DeploymentCoverageItem> deploymentCoverageItems)
Microsoft.VisualStudio.QualityTools.TMI.dll!Microsoft.VisualStudio.TestTools.TestManagement.DeploymentManager.DoDeployment(Microsoft.VisualStudio.TestTools.Common.TestRun run, Microsoft.VisualStudio.TestTools.Common.FileCopyService fileCopyService)
Microsoft.VisualStudio.QualityTools.TMI.dll!Microsoft.VisualStudio.TestTools.TestManagement.ControllerProxy.SetupTestRun(Microsoft.VisualStudio.TestTools.Common.TestRun run, bool isNewTestRun, Microsoft.VisualStudio.TestTools.Common.FileCopyService fileCopyService, Microsoft.VisualStudio.TestTools.TestManagement.DeploymentManager deploymentManager)
Microsoft.VisualStudio.QualityTools.TMI.dll!Microsoft.VisualStudio.TestTools.TestManagement.ControllerProxy.SetupRunAndListener(Microsoft.VisualStudio.TestTools.Common.TestRun run, Microsoft.VisualStudio.TestTools.Common.FileCopyService fileCopyService, Microsoft.VisualStudio.TestTools.TestManagement.DeploymentManager deploymentManager)
Microsoft.VisualStudio.QualityTools.TMI.dll!Microsoft.VisualStudio.TestTools.TestManagement.ControllerProxy.QueueTestRunWorker(object state)
mscorlib.dll!System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(object state)
mscorlib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx)
mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx)
mscorlib.dll!System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
mscorlib.dll!System.Threading.ThreadPoolWorkQueue.Dispatch()
mscorlib.dll!System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()
[Native to Managed Transition]
The stack trace suggest that the fact that I am testing a signed assembly may trigger the error.
After some experimenting, I discovered that I could solve this problem by disabling code coverage for the test run in the test run configuration file. You can do this by opening the LocalTestRun.testrunconfig file (located under solution items) -> Data and Diagnostics then disable 'Code coverage (Visual Studio 2010)'
Sometimes, setup programs shows the Windows file copy dialog, like this one:
This often appears during driver-level application installation, either on Windows XP or Windows 7.
Which API can perform that?
EDIT
Actually, there is no Cancel button at all on the real dialog box.
The Windows API is called SHFileOperation.
Its signature in C# language is
[DllImport("shell32.dll",CharSet = CharSet.Unicode)]
static extern int SHFileOperation([In] ref SHFILEOPSTRUCT lpFileOp);
If you like an example you could look at this page on PInvoke
This instead is the link to the MSDN documentation on SHFileOperation
The Windows API SHFileOperation is declared as follows:
[DllImport("shell32.dll",CharSet = CharSet.Unicode)]
static extern int SHFileOperation(ref SHFILEOPSTRUCT lpFileOp);
Specifying [In] for ref SHFILEOPSTRUCT lpFileOp prevents receiving the pointer to any remapped files in ref SHFILEOPSTRUCT.hNameMappings when FOF_WANTMAPPINGHANDLE flag is set.