I'm trying to use dblinq in my IronPython application but am having some problems getting started. When trying to import dblinq classes,using clr.AddReference() it does not seem to see dblinq.
I can build but not access the library
import clr
clr.AddReference("DbLinq")
clr.AddReference("System.Data.Linq")
from System.Data.Linq import DataContext
exit = raw_input("press any key to quit")
1:
My dblinq source is in a subfolder called Resources
clr.AddReferenceToFileAndPath("Resources/DbLinq.dll") => file not found
clr.AddReference("DbLinq") => could not add reference to dblinq
clr.AddReferenceToFileAndPath("C:/Development/DBLinq2/Dblinq.dll" => success
but still cannot use the classes using from DbLinq import ...
Solution
import clr
clr.AddReferenceToFileAndPath("%s\Resources\DbLinq.dll" %os.getcwd())
clr.AddReference("DbLinq")
from Npgsql import *
from DbLinq import Data
For libraries like DbLinq that come with dependencies or are split into several DLLs/modules you can programmatically add their location to allow the runtime to find all required files.
import sys
sys.path.append(r"C:\Temp\DbLinq-0.20.1")
You can then reference all required assemblies as usual:
clr.AddReference("DbLinq")
If there is one primary assembly you can also use clr.AddReferenceToFileAndPath (with an absolute path) which will implicitly add the referenced assemblies location to the path.
clr.AddReference(r"C:\Temp\DbLinq-0.20.1\DbLinq.dll")
Related
previously I was using
"google.golang.org/api"=>v0.10.0
in my go.mod file and I was able to import
gensupport "google.golang.org/api/gensupport"
But with new
"google.golang.org/api"=>v0.103.0
I was unable to import gensupport and as I and my colleague have investigated, gensupport was shifted to
"google.golang.org/api/internal/gensupport"
but while using this import there is one error saying
Use of the internal package is not allowed
So now how I will be able to use gensupport with new "google.golang.org/api"=>v0.103.0 version.
Your only option is to vendor an older version of the library.
This package has been marked for internal use for a long time and was also marked to allow for breakages. See https://github.com/googleapis/google-api-go-client/issues/416 for options.
After upgrading Xcode to 7.3, I just found that some modules are stricken out while importing, like in this screenshot:
But after adding the module (so just pressing enter) everything is fine. What does that mean? The module here is written in Swift and works fine.
This is a bug. We have fixed it in 218010af, which should be included in the Swift 2.2.1 release and is included in the 2016-04-12-a developer snapshot.
The strikethrough occurs if you try to import a module that has already been imported by your file or module:
In this case, I have already imported Foundation (which implicitly imports CoreFoundation), so Xcode is telling you that there is no need to import either module again.
It usually happens when a framework is already imported by any other framework you have already been imported.
For example, UIKit is already imported with Foundation so you don't need to import it manually.
I changed the order of the imports
import Foundation
import UIKit
import LayerKit
import Atlas < red line
import Foundation
import UIKit
import Atlas
import LayerKit
Some notes that may be causing it:
LayerKit importing Atlas even though LayerKit is the lower level API
Atlas is the UI layer
Both were Cocoapod imports
Error appeared when I created an 2nd Schema for App Store/Enteprise
releases and cleaned one and switch to the other.
Deleting Derived
Data didnt clear it.
So tried rearranging them and red line disappeared
I have an OSX project (xcode plugin) and I want to use the ReactiveCocoa paradigms in it (PromiseKit andBrightFutures` are the other implementations of the same paradigms so I need to import at least one from these 3 frameworks/libraries).
The problem is it seems impossible to import them as compiled frameworks into my project because it is plugin. In my project I used dispatch_async and dispatch_after functions only but their nested blocks look awful.
The only solution I found is import one from these frameworks as sources but I don't know how to detach their code. So could anybody help with this trouble? Or maybe are there any other similar libraries which are already represented as source files only?
Short Answer:
Use a dependency manager like Cocoapods or Carthage.
Longer Answer: You can do it manually, but even if you don't want to use any of those, you can look at the .podspec file and see how it's supposed to be used. For example BrightFutures.podspec says:
s.source_files = 'BrightFutures/*.swift'
s.dependency 'Result', '0.6.0-beta.6'
That means that you need to import all the .swift files inside the BrightFutures folder, and that it won't work unless you also import the files from another project called Result.
But please, just let the tools do that for you. You'll be happier. :)
Let's say I have a file called myAppDelegate.swift and another called myWindowController.swift. How do I import myWindowController into myAppDelegate, because currently if I just type
import myWindowController
It says that it can't recognize that module. What's the step-by-step process for importing swift files into other swift files in Xcode6?
You don't need to import swift files in the same target into each other. The import statement is used for importing entire modules, not individual files. myWindowController should be accessible from myAppDelegate without needing to import.
I am having a hard time to properly set up the environment for T4 to recognize the Sqlite provider. Steps I have taken:
Add assemblies and imports to in .tt
<## assembly name="\System.Data.SQLite.dll" #>
<## import namespace="System.Data.SQLite" #>
At the beginning of tt, add SQLite as one of the providers.
// add sqlite
try
{
var dataSet = ConfigurationManager.GetSection("system.data") as System.Data.DataSet;
dataSet.Tables[0].Rows.Add("SQLite Data Provider"
, ".Net Framework Data Provider for SQLite"
, "System.Data.SQLite"
, "System.Data.SQLite.SQLiteFactory, System.Data.SQLite");
}
catch (System.Data.ConstraintException) { }
I verified in SQLite is one of the providers in DbProviderFactories.
This didn't get SQLite to load by T4. Under a normal application, a SQLite entry would be added to the App.config section. SQLite somehow preloads a native dll. I suspect the preloading is the problem.
After some digging, I resolved the problem by installing System.Data.Sqlite. The installer puts the library in the GAC. The additional code above is not necessary. I was trying to avoid the GAC, but didn't find another way out.